https://github.com/shigma/deconstruct-merge
A simple library for merging complex options.
https://github.com/shigma/deconstruct-merge
Last synced: 2 months ago
JSON representation
A simple library for merging complex options.
- Host: GitHub
- URL: https://github.com/shigma/deconstruct-merge
- Owner: shigma
- License: mit
- Created: 2019-03-09T13:48:38.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T14:16:00.000Z (about 6 years ago)
- Last Synced: 2024-10-04T11:41:19.170Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deconstruct-merge
[](https://www.npmjs.com/package/deconstruct-merge)
A _simple_ library for merging _complex_ options. First deconstruct, then merge.
## Example
```js
const Mergeable = require('deconstruct-merge')const config = new Mergeable({
foo: 'flat',
bar: 'array',
baz: [
'assign',
'override',
],
})config
.merge({
foo: 1,
baz: [
{ a: 1 },
{ b: 2 },
],
})
.merge({
foo: [2],
bar: [2],
})
.merge(undefined)
.merge({
bar: 3,
baz: [
{ a: 2, b: 3 },
{ c: 4 },
]
})
.value()// output:
// { foo: [ 1, 2 ],
// bar: [ [ 2 ], 3 ],
// baz: [ { a: 2, b: 3 }, { c: 4 } ] }
```