Re: Any chance for an `Object.assignProperties` ?

2020-02-13 Thread Andrea Giammarchi
Anyway, if anyone is interested, I've published the `assign-properties` module [1] [1] https://github.com/WebReflection/assign-properties#readme On Thu, Feb 13, 2020 at 7:51 PM Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > The fact `assign` doesn't copy descriptors and has potential

Re: Any chance for an `Object.assignProperties` ?

2020-02-13 Thread Andrea Giammarchi
The fact `assign` doesn't copy descriptors and has potential side-effects is documented extensively though, meaning there is room for improvement, or simply a missing native way to do that, like it was for `getOwnPropertyDescriptors`, that following your logic should've never landed. But I guess

Re: Any chance for an `Object.assignProperties` ?

2020-02-13 Thread Jordan Harband
It seems like it’s the exact implementation you want, just for 1 object instead of N. Object.assign was added because versions of it were all over the web, used very frequently. How frequent is the pattern where people want to copy descriptors, such that it would deserve reification in the

Re: Any chance for an `Object.assignProperties` ?

2020-02-13 Thread Andrea Giammarchi
That has nothing to do with this, right? ```js const {assign, defineProperties, getOwnPropertyDescriptors} = Object; const assignProperties = (base, ...mixins) => defineProperties( base, mixins.reduce( (descriptors, mixin) => assign( descriptors,

Re: Any chance for an `Object.assignProperties` ?

2020-02-13 Thread Jordan Harband
`Object.defineProperties(target, Object.getOwnPropertyDescriptors(source))`? On Thu, Feb 13, 2020 at 2:24 AM Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > Both `Object.assign` and `{...extend}` suffer a tiny gotcha: properties > are never assigned, neither retrieved, as accessors,

Any chance for an `Object.assignProperties` ?

2020-02-13 Thread Andrea Giammarchi
Both `Object.assign` and `{...extend}` suffer a tiny gotcha: properties are never assigned, neither retrieved, as accessors, with side-effects too. Example: ```js const Counter = { _count: 0, get count() { return this._count++; } }; const incr1 = Object.assign({}, Counter); const incr2