Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@exuanbo
Copy link
Contributor

@exuanbo exuanbo commented Dec 25, 2023

Follow up on #25

In real-world use, there won't be tons of symbol keys in an object, so any slowdown in performance shouldn't be a big deal.

Also, I think we might need some more test cases for this one.


Reference: how esbuild transforms spread syntax:

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
const state = { count: 1 };
const newState = __spreadValues({}, state);

https://hyrious.me/esbuild-repl/?version=0.19.10&t=const+state+%3D+%7B+count%3A+1+%7D%3B%0Aconst+newState+%3D+%7B+...state+%7D%3B&o=--target%3Des6

@exuanbo
Copy link
Contributor Author

exuanbo commented Dec 25, 2023

The CI failure comes from coveralls 🤔

@unadlib unadlib merged commit 6d8600e into unadlib:main Dec 25, 2023
@exuanbo exuanbo deleted the align-shallow-copy-with-spread branch December 26, 2023 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants