# merge-descriptors

> Merge objects using their property descriptors

Latest version **2.0.0** (published 2023-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install merge-descriptors
pnpm add merge-descriptors
yarn add merge-descriptors
bun add merge-descriptors
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-11-16 |
| First published | 2013-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 153 |
| Maintainers | juliangruber, sindresorhus, tjholowaychuk, dougwilson, jonathanong, jongleberry |
| Keywords | merge, descriptors, object, property, properties, merging, getter, setter |

## Links

- npm: https://www.npmjs.com/package/merge-descriptors
- Repository: https://github.com/sindresorhus/merge-descriptors
- Homepage: https://github.com/sindresorhus/merge-descriptors#readme
- Issues: https://github.com/sindresorhus/merge-descriptors/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/merge-descriptors

## Recent versions

- 2.0.0 (latest) — 2023-11-16
- 1.0.3 — 2023-11-16
- 1.0.2 — 2023-11-16
- 1.0.1 — 2016-01-17
- 1.0.0 — 2015-03-01
- 0.0.2 — 2013-12-14
- 0.0.1 — 2013-10-29

## README

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

---
_Source: https://npm.io/package/merge-descriptors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
