match-conditions
v1.0.16
Published
Match a condition object against a key-value collection using a domain specific syntax.
Downloads
182
Readme
match-conditions
Match a set of conditions for a collection of key-value pairs. Conditions are able to access nested keys.
Install
yarn add match-conditions
Usage
import { normalizeCondition, matchValuesWithCondition } from 'match-conditions'
// true
matchValuesWithCondition(
normalizeCondition({
a: '2'
}),
{
a: '2'
}
)
// false
matchValuesWithCondition(
normalizeCondition({
a: '3'
}),
{
a: '2'
}
)
// true
matchValuesWithCondition(
normalizeCondition({
any: {
a: '3 | 2',
b: 'c'
}
}),
{
a: '2',
b: 'a'
}
)