Fork of fast-deep-equal
equal(a, b, options)
- options:
- key:
depth
- type: integer
- default value =
Infinity
- summary:
- provides fine grain control to configure how deep to recurse into a data structure to test equality
- typically, you're given 2 choices:
- shallow
- equivalent to:
{depth: 1}
- equality occurs when either:
a === b
a
andb
are both: Arrays, Objects, ES6 Maps- same length
- all children:
a[i] === b[i]
- equivalent to:
- deep
- equivalent to:
{depth: Infinity}
- equality occurs when either:
- shallow equality is true
- for all children where:
a[i] !== b[i]
a[i]
andb[i]
are both: Arrays, Objects, ES6 Maps- same length
- all children:
a[i][j]
andb[i][j]
exhibit deep equality
- equivalent to:
- shallow
- typically, you're given 2 choices:
- provides fine grain control to configure how deep to recurse into a data structure to test equality
- default value =
- type: integer
- key:
shallow
- type: boolean
- default value =
false
- summary:
true
- equivalent to:
{depth: 1}
- equivalent to:
false
- equivalent to:
{depth: Infinity}
- equivalent to:
- default value =
- type: boolean
- key:
react
- type: boolean
- default value =
false
- summary:
- avoid traversing React elements'
_owner
_owner
contains circular references and is not needed when comparing the actual elements
- avoid traversing React elements'
- default value =
- type: boolean
- key:
es6
- type: Object || boolean
- Object
- keys can include:
['Map', 'Set', 'ArrayBuffer']
- values are boolean
- keys can include:
- boolean
- shortcut for assigning this boolean value to all Object keys
- default value =
false
- Object
- type: Object || boolean
- key:
- notes:
- the
shallow
key provides a quick way to configure thedepth
key with one of the two most common use cases (ie: shallow and deep)- these two keys shouldn't be used together
depth
takes priority
- these two keys shouldn't be used together
- the
- options:
npm install --save '@warren-bank/fast-equal'
const equal = require('@warren-bank/fast-equal')
const a = {foo: 'bar', hello: 'world'}
const b = {...a}
if (equal(a, b, {shallow: true})) {
// profit!
}
- copyright: Evgeny Poberezkin
- license: MIT