Skip to content

Latest commit

 

History

History
49 lines (41 loc) · 624 Bytes

README.md

File metadata and controls

49 lines (41 loc) · 624 Bytes

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'
  }
)