Skip to content

Match a condition object against a key-value collection using a domain specific syntax.

License

Notifications You must be signed in to change notification settings

andreiglingeanu/match-conditions

Repository files navigation

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

About

Match a condition object against a key-value collection using a domain specific syntax.

Resources

License

Stars

Watchers

Forks

Packages

No packages published