node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

object-router

object-router  Build Status

Route your functions with pattern matching. Inspired by seneca.

object-router is based on bloomrun, so all patterns will be matched in insertion order.

Install

npm i object-router --save

Example

'use strict'
 
var router = require('object-router')()
 
router.add({
  cmd: 'hello'
}, function (msg, cb) {
  cb(null, {
    result: 'hello ' + msg.name
  })
})
 
router.act({
  cmd: 'hello',
  name: 'world'
}, console.log)

License

MIT