Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
load-helpers
Advanced tools
Load helpers with patterns, as an object, key-value pair, or module.
Load helpers with patterns, as an object, key-value pair, or module.
Install with npm:
$ npm install --save load-helpers
Install with yarn:
$ yarn add load-helpers
Create an instance of Loader
with the given options
.
Params
options
{Object}Example
var Loader = require('load-helpers');
var loader = new Loader();
Register a helper function by name
.
Params
name
{String}fn
{Function}options
{Object}Example
loader.addHelper('foo', function() {
// do stuff
});
Register an object of helper functions.
Params
helpers
{Object}options
{Object}Example
loader.addHelpers({
foo: function() {},
bar: function() {},
baz: function() {}
});
Load one or more helpers from a filepath, glob pattern, object, or an array of any of those things. This method detects the type of value to be handled then calls one of the other methods to do the actual loading.
Params
helpers
{Object}options
{Object}returns
{Object}: Returns the views from loader.helpers
Example
var loader = new Loader();
console.log(loader.load(['foo/*.hbs', 'bar/*.hbs']));
console.log(loader.load({path: 'a/b/c.md'}));
console.log(loader.load('index', {path: 'a/b/c.md'}));
Customize how dynamically-added helpers are named as they're loaded.
Examples
Pass a custom renameHelper
function on the ctor.
var loader = new Loader({
renameHelper: function(key) {
// simple camel-case
return key.replace(/\W(.)/g, function(_, ch) {
return ch.toUpperCase();
});
}
});
loader.load('for-own');
console.log(loader.helpers);
// { 'forOwn': [Function: forOwn] }
Or to only renamed specific helpers, you can pass the renameHelper
function to any of the methods.
loader.load('for-own', {
renameHelper: function(key) {
// simple camel-case
return key.replace(/\W(.)/g, function(_, ch) {
return ch.toUpperCase();
});
}
});
console.log(loader.helpers);
// { 'forOwn': [Function: forOwn] }
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Commits | Contributor |
---|---|
39 | jonschlinkert |
3 | doowb |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.5.0, on April 20, 2017.
FAQs
Load helpers with patterns, as an object, key-value pair, or module.
The npm package load-helpers receives a total of 19,404 weekly downloads. As such, load-helpers popularity was classified as popular.
We found that load-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.