Skip to content

bendrucker/matchy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

matchy Build Status

Match shallow objects

Install

$ npm install --save matchy

Usage

var Match = require('matchy')

var match = Match([
  {type: 'FooType'},
  {name: /Bar$/},
  {message: (value) => value && value.split('').reverse().join('') === 'raBooF'}
])

match({type: 'FooType'})
//=> true

match({name: 'FooBar'})
//=> true

match({name: 'FooBaz'})
//=> false

API

Match(data) -> function

data

Required
Type: object

A shallow object where the keys are error data keys and the values are:

  • Strings or numbers (checked for strict equality)
  • Regular expressions
  • Functions (called with the error value for that key)

License

MIT © Ben Drucker

About

Match shallow objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published