https://github.com/shigma/deconstruct-merge
A simple library for merging complex options.
https://github.com/shigma/deconstruct-merge
Last synced: about 1 year 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T14:16:00.000Z (over 7 years ago)
- Last Synced: 2025-06-03T11:30:29.104Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- 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 } ] }
```