Sugar Merge
Deep merge utils with a little sugar on top
Merge
const merge = ; const a = foo: bar: baz: 'sis' qux: 'boom' ; const b = foo: 'bar[+]': xyzzy: 'bah' ; ; /** * returns: * { * foo: { * bar: [ * { * baz: 'sis' * }, * { * qux: 'boom' * }, * { * xyzzy: 'bah' * } * ] * } * } */ const c = foo: 'bar[-]': xyzzy: 'bah' ; ; /** * returns: * { * foo: { * bar: [ * { * xyzzy: 'bah' * }, * { * baz: 'sis' * }, * { * qux: 'boom' * } * ] * } * } */ const d = foo: 'bar[1,0]': xyzzy: 'bah' ; ; /** * returns: * { * foo: { * bar: [ * { * baz: 'sis' * }, * { * xyzzy: 'bah' * }, * { * qux: 'boom' * } * ] * } * } */
Set
const set = ; const obj = foo: bar: baz: 1 2 3 ; ; /** * returns: * { * foo: { * bar: [ * { * baz: [ * 1, * 2, * 3, * { * qux: 'xyzzy' * } * ] * } * ] * } * } */ ; /** * returns: * { * foo: { * bar: [ * { * baz: [ * { * qux: 'xyzzy' * }, * 1, * 2, * 3 * ] * } * ] * } * } */ ; /** * returns: * { * foo: { * bar: [ * { * baz: [ * 1, * { * qux: 'xyzzy' * }, * 2, * 3 * ] * } * ] * } * } */
License
MIT