function-switch
v1.0.0
Published
switch between regexp cases, globs. switches are composeable with each other
Downloads
7
Readme
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