https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
+36 -30
View File
@@ -1,49 +1,55 @@
# merge-descriptors
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
> Merge objects using their property descriptors
Merge objects using descriptors.
## Install
```sh
npm install merge-descriptors
```
## Usage
```js
var thing = {
get name() {
return 'jon'
}
import mergeDescriptors from 'merge-descriptors';
const thing = {
get name() {
return 'John'
}
}
var animal = {
const animal = {};
}
mergeDescriptors(animal, thing);
merge(animal, thing)
animal.name === 'jon'
console.log(animal.name);
//=> 'John'
```
## API
### merge(destination, source)
### merge(destination, source, overwrite?)
Redefines `destination`'s descriptors with `source`'s. The return value is the
`destination` object.
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.
### merge(destination, source, false)
Returns the modified destination object.
Defines `source`'s descriptors on `destination` if `destination` does not have
a descriptor by the same name. The return value is the `destination` object.
#### destination
## License
Type: `object`
[MIT](LICENSE)
The object to receive properties.
[npm-image]: https://img.shields.io/npm/v/merge-descriptors.svg
[npm-url]: https://npmjs.org/package/merge-descriptors
[travis-image]: https://img.shields.io/travis/component/merge-descriptors/master.svg
[travis-url]: https://travis-ci.org/component/merge-descriptors
[coveralls-image]: https://img.shields.io/coveralls/component/merge-descriptors/master.svg
[coveralls-url]: https://coveralls.io/r/component/merge-descriptors?branch=master
[downloads-image]: https://img.shields.io/npm/dm/merge-descriptors.svg
[downloads-url]: https://npmjs.org/package/merge-descriptors
#### source
Type: `object`
The object providing properties.
#### overwrite
Type: `boolean`\
Default: `true`
A boolean to control overwriting of existing properties.