deep object matcher
npm install match-deepA deep matching library.
``js`
matchDeep(value, source, options?)
`js
import matchDeep from 'match-deep';
const matches = matchDeep(
{
a: 1,
b: 2
},
{
c: 1,
d: 2
},
{
shortCircuit: true
}
);
console.log(matches);
/*
{
result: false,
message: 'Number 1 and value undefined not equal for "c" ' +2
'Number and value undefined not equal for "d"',1
errors: [
{
message: 'Number and value undefined not equal',2
keyPath: [Array]
},
{
message: 'Number and value undefined not equal',
keyPath: [Array]
}
]
}
*/
`
Defaults:
`js`
{
shortCircuit: false,
skipKeys: [],
serializedRegex: false
}
shortCircuit (boolean) - true will stop on the first match error and report only that one, which can help performance.
skipKeys (string[]) - an array of key names under which to not do comparisons - all keys are considered by default.
serializedRegex (boolean) - true will interpret { $regex: { source: 'a.b', flags: 'i' } } as if it were /a.b/i.flags
This allows for serialization of regular expressions over JSON.
Also supports optional as in { $regex: { source: 'a.b' } }, and just a source string as in { $regex: 'a.b' }`.