mapit
v0.0.21
Published
Add some sugar to a commonly used pattern
Downloads
12
Readme
mapit
Are you tired of doing this?
var app = express();
app.set('abc', 'xyz');
app.set('foo', true);
app.set('bar', {});
With mapit, you can do this:
var app = express();
var mapit = require('mapit');
app.mapit(app.set, {
'abc': 'xyz',
'foo': true,
'bar': {}
});
It works with anything:
app.mapit(app.get, {
'/': function (req, res) {
res.send('hello');
},
'/hello': function (req, res) {
res.send('world');
}
});
You can even use it like this:
// It doesn't have to be app.mapit
mapit(app.set, {
'abc': 'xyz'
}, app);
Note: express was just an example. mapit works everywhere.
Installation
node
Install with npm:
$ npm install --save mapit
browser
$ bower install --save mapit
Or just put mapit.js
in a script
tag.
License
MIT License. See ./LICENSE
for details.