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.
helper-cache
Advanced tools
Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.
Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.
npm i helper-cache --save
Create an instance of Helpers
, optionally passing default options
.
options
{Object}: Default options to use.
bind
{Boolean}: Bind functions to this
. Defaults to false
.thisArg
{Boolean}: The context to use.var Helpers = require('helper-cache');
var helpers = new Helpers();
Register a helper.
name
{String}: The name of the helper.fn
{Function}: Helper function.helpers.addHelper('lower', function(str) {
return str.toLowerCase();
});
Register an async helper.
key
{String}: The name of the helper.fn
{Function}: Helper function.helpers.addAsyncHelper('foo', function (str, callback) {
callback(null, str + ' foo');
});
Load a glob or object of helpers.
key
{String}: The name of the helper.fn
{Function}: Helper function.// glob patterns
helpers.addHelpers('helpers/*.js');
helpers.addHelpers(['helpers/a.js', 'helpers/{b,c}.js']);
// object of helper functions
helpers.addHelpers({
a: function() {},
b: function() {},
c: function() {},
});
See load-helpers for issues, API details and the full range of options.
Load a glob or object of async helpers.
key
{String}: The name of the helper.fn
{Function}: Helper function.// glob patterns
helpers.addAsyncHelpers('helpers/*.js');
helpers.addAsyncHelpers(['helpers/a.js', 'helpers/{b,c}.js']);
// object of helper functions
helpers.addAsyncHelpers({
a: function() {},
b: function() {},
c: function() {},
});
See load-helpers for issues, API details and the full range of options.
Get a registered helper.
key
{String}: The helper to get.returns
{Object}: The specified helper. If no key
is passed, the entire cache is returned.helpers.getHelper('foo');
Get a registered async helper.
key
{String}: The helper to get.returns
{Object}: The specified helper. If no key
is passed, the entire cache is returned.helpers.getAsyncHelper('foo');
Getter method to resolve async helper values that were called during the render process. Rendering is done by whatever engine you've registered the helpers with.
content
{String}: Rendered string containing async idscb
{Function}helper.resolveHelper(str, function (err, content) {
if (err) return done(err);
// do stuff with `content`
done();
});
Jon Schlinkert
Brian Woodward
Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb on February 14, 2015.
FAQs
Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.
The npm package helper-cache receives a total of 27,652 weekly downloads. As such, helper-cache popularity was classified as popular.
We found that helper-cache 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.