1.0.0 • Published 8 years ago

function-switch v1.0.0

Weekly downloads
4
License
-
Repository
github
Last release
8 years ago

function-switch

switch between regexp cases, globs. switches are composeable with each other

Installation

npm install function-switch

Usage

let fn = Switch({
  'team.*.hi': () => 'hi',
  'team.*': () => 'team',
  b: () => 'b'
  '*': () => 'default'
})

assert.equal(fn('team'), null)
assert.equal(fn('team.hello')(), 'team')
assert.equal(fn('team.hello.hi')(), 'hi')
assert.equal(fn('b')(), 'b')

License

MIT