3.1.3 • Published 6 years ago
@warren-bank/fast-equal v3.1.3
fast-equal
Fork of fast-deep-equal
Differences:
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 === baandbare 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 _ownercontains 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
shallowkey provides a quick way to configure thedepthkey with one of the two most common use cases (ie: shallow and deep)- these two keys shouldn't be used together
depthtakes priority
- these two keys shouldn't be used together
- the
- options:
Install:
npm install --save '@warren-bank/fast-equal'Usage:
const equal = require('@warren-bank/fast-equal')
const a = {foo: 'bar', hello: 'world'}
const b = {...a}
if (equal(a, b, {shallow: true})) {
// profit!
}Legal:
- copyright: Evgeny Poberezkin
- license: MIT