Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/mcollina/object-router
- Owner: mcollina
- License: mit
- Created: 2015-08-22T09:44:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-09T07:13:30.000Z (over 9 years ago)
- Last Synced: 2024-12-25T10:21:33.604Z (15 days ago)
- Language: JavaScript
- Size: 148 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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