1.0.0 • Published 8 years ago

matchy v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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