Files
med-notes/.pnpm-store/v10/files/85/128c98d87d66d4a21d1bead9103dfd33619667dcc4db090e12c32c6dc7998c3d2f6ff203f088295aee6ac70a03b670e1541d46aa0f97fee27eda0b9ed6a8c8
2025-06-26 03:35:15 +00:00

56 lines
930 B
Plaintext

# 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.