Spaces:
Running
Running
File size: 930 Bytes
1719261 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# merge-descriptors
> Merge objects using their property descriptors
## Install
```sh
npm install merge-descriptors
```
## Usage
```js
import mergeDescriptors from 'merge-descriptors';
const thing = {
get name() {
return 'John'
}
}
const animal = {};
mergeDescriptors(animal, thing);
console.log(animal.name);
//=> 'John'
```
## API
### merge(destination, source, overwrite?)
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.
#### destination
Type: `object`
The object to receive properties.
#### source
Type: `object`
The object providing properties.
#### overwrite
Type: `boolean`\
Default: `true`
A boolean to control overwriting of existing properties.
|