https://github.com/silverwind/deepie-merge
Yay, another deep merge
https://github.com/silverwind/deepie-merge
Last synced: 7 months ago
JSON representation
Yay, another deep merge
- Host: GitHub
- URL: https://github.com/silverwind/deepie-merge
- Owner: silverwind
- License: bsd-2-clause
- Created: 2024-03-08T21:01:25.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-14T17:47:13.000Z (over 1 year ago)
- Last Synced: 2025-03-13T00:02:29.386Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 682 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deepie-merge
[](https://www.npmjs.org/package/deepie-merge) [](https://www.npmjs.org/package/deepie-merge) [](https://packagephobia.com/result?p=deepie-merge)
> Yay, another deep merge
## Usage
```console
npm i deepie-merge
```
```js
import {deepMerge} from "deepie-merge";
deepMerge({a: [1]}, {a: [2]});
// => {a: [2]}
deepMerge({a: [1]}, {a: [2]}, {arrayExtend: true});
// => {a: [1, 2]}
deepMerge({a: [1], b: [1]}, {a: [2], b: [2]}, {arrayExtend: ["a"]});
// => {a: [1, 2], b: [2]}
```
## API
### deepMerge(a, b, options)
Deep-merge `b` into `a`.
- `a` *any*: Destination value
- `b` *any*: Source value
- `options` *object*:
- `arrayExtend` *boolean* or *string[]*: Whether to extend arrays instead of replacing them. When passed a string array, it will only extend the object keys provided in that array.
- `maxRecursions` *number*: Amount of nesting levels to recurse into. Default: `20`
© [silverwind](https://github.com/silverwind), distributed under BSD licence