Skip to content
Add some sugar to a commonly used pattern
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE Readme, bower.json, tests.
README.md Add thisArg to mapit function.
bower.json
mapit.js
package.json mapit v0.0.21
test.js

README.md

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:

$ bower install --save mapit

Or just put mapit.js in a script tag.

License

MIT License. See ./LICENSE for details.

Something went wrong with that request. Please try again.