load-helpers
Load helpers with patterns, as an object, key-value pair, or module.
Install
Install with npm
$ npm i load-helpers --save
Usage
var loader = require('load-helpers');
var cache = {};
var helpers = loader(cache);
helpers({
a: function(),
b: function(),
c: function()
});
helpers('d', function() {});
helpers('e', function() {});
helpers('f', function() {});
helpers('helpers/*.js');
helpers('j');
Results in:
{
a: function(){},
b: function(){},
c: function(){},
d: function(){},
e: function(){},
f: function(){},
g: function(){},
h: function(){},
i: function(){},
j: function(){}
}
options.renameKey
When requiring helpers from a filepath or node_modules
a renameKey
function may be passed on the helper's options to customize how the key is named:
Example
helpers('for-own', {
renameKey: function (key) {
return key.replace(/\W(.)/g, function (_, ch) {
return ch.toUpperCase();
});
}
});
Related projects
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on October 21, 2015.