@magic/deep
Work with deeply nested objects and arrays.
install
npm i --save --save-exact @magic/deep
import
import { equal, flatten, loop, merge } from '@magic/deep'
import deep from '@magic/deep'
Currently implemented:
deep.equal
deep.equal(['shallow', ['deep']], ['shallow', ['deep']])
deep.equals, deep.eq
deep.different
deep.different(['shallow', ['deep']], ['shallow', ['deep']])
deep.diff
deep.flatten
deep.flatten(['shallow', ['deep']])
deep.loop
const add = e => e + 1
const items = [1, 2, [3]]
deep.loop(add, items)
deep.loop(items, add)
deep.merge
deep.merge({ obj1Key: { val: 1 } }, { obj2Key: { val: 2 } } )
deep.merge({ key: { val: 1, str: 'test' } }, { key: { val: 2, str: 'overwritten' } })
Changelog
0.1.0
use ecmascript modules instead of commonjs.
0.1.1
- update readme
- also export deep.eq alias for deep.equal
0.1.2
- require node 13.5.0
- use deep.equal and deep.different from @magic/types
0.1.3
bump required node version to 14.2.0
0.1.4
update dependencies
0.1.5
- bump required node version to 14.15.4
- update dependencies
0.1.6
- merge now checks if o2.hasOwnProperty is a function before using it to check if we should overwrite keys of o1 or not.
0.1.7 - unreleased
...