Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mcollina/object-router

Route your functions with pattern matching
https://github.com/mcollina/object-router

Last synced: 12 days ago
JSON representation

Route your functions with pattern matching

Awesome Lists containing this project

README

        

# object-router  [![Build Status](https://travis-ci.org/mcollina/object-router.png)](https://travis-ci.org/mcollina/object-router)

Route your functions with pattern matching. Inspired by
[seneca](http://npm.im/seneca).

__object-router__ is based on [bloomrun](http://npm.im/bloomrun), so all patterns will be matched in insertion order.

## Install

```
npm i object-router --save
```

## Example

```js
'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)

console.log(router.list())
```

## License

MIT