.. | |||
index.d.ts | 1 month ago | ||
index.js | 1 month ago | ||
license | 1 month ago | ||
package.json | 1 month ago | ||
readme.md | 1 month ago |
Merge objects using their property descriptors
npm install merge-descriptors
import mergeDescriptors from 'merge-descriptors'; const thing = { get name() { return 'John' } } const animal = {}; mergeDescriptors(animal, thing); console.log(animal.name); //=> 'John'
Merges "own" properties from a source to a destination object, including non-enumerable and accessor-defined properties. It retains original values and descriptors, ensuring the destination receives a complete and accurate copy of the source's properties.
Returns the modified destination object.
Type: object
The object to receive properties.
Type: object
The object providing properties.
Type: boolean
Default: true
A boolean to control overwriting of existing properties.