Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

base-helpers

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-helpers - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

README.md

48

index.js

@@ -67,3 +67,6 @@ /*!

app.define('helpers', function() {
app.define('helpers', function(name, helpers) {
if (typeof name === 'string' && utils.isHelperGroup(helpers)) {
return this.helperGroup.apply(this, arguments);
}
sync.apply(sync, arguments);

@@ -108,3 +111,6 @@ return this;

app.define('asyncHelpers', function() {
app.define('asyncHelpers', function(name, helpers) {
if (typeof name === 'string' && utils.isHelperGroup(helpers)) {
return this.helperGroup.apply(this, arguments);
}
async.apply(async, arguments);

@@ -205,8 +211,23 @@ return this;

debug('registering helper group "%s"', name);
helpers = utils.arrayify(helpers);
var type = isAsync ? 'async' : 'sync';
this._.helpers[type][name] = this._.helpers[type][name] || {};
var loader = utils.loader(this._.helpers[type][name], {async: isAsync});
var group = this._.helpers[type][name] || (this._.helpers[type][name] = {});
if (typeof helpers === 'function' && utils.isHelperGroup(helpers)) {
Object.defineProperty(helpers, 'isGroup', {
enumerable: false,
configurable: false,
value: true
});
if (isAsync === true) {
decorateHelpers(helpers, helpers, isAsync);
}
decorateHelpers(helpers, group, isAsync, true);
this._.helpers[type][name] = helpers;
return this;
}
helpers = utils.arrayify(helpers);
var loader = utils.loader(group, {async: isAsync});
loader.call(loader, helpers);

@@ -217,1 +238,16 @@ return this;

};
function decorateHelpers(oldHelpers, newHelpers, isAsync, override) {
for (let key in newHelpers) {
if (newHelpers.hasOwnProperty(key)) {
// "newHelpers" is the helpers being passed by the user
if (override === true && oldHelpers[key]) continue;
let fn = newHelpers[key];
if (typeof fn === 'function') {
fn.async = isAsync;
}
oldHelpers[key] = fn;
}
}
}

29

package.json
{
"name": "base-helpers",
"description": "Adds support for managing template helpers to your base application.",
"version": "0.1.1",
"version": "0.2.0",
"homepage": "https://github.com/node-base/base-helpers",

@@ -24,24 +24,35 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"dependencies": {
"debug": "^2.2.0",
"debug": "^2.6.0",
"define-property": "^0.2.5",
"is-valid-app": "^0.1.0",
"lazy-cache": "^2.0.1",
"load-helpers": "^0.2.11"
"is-valid-app": "^0.2.1",
"isobject": "^3.0.0",
"lazy-cache": "^2.0.2",
"load-helpers": "^0.3.1"
},
"devDependencies": {
"base": "^0.11.0",
"gulp-format-md": "^0.1.9",
"mocha": "^2.5.3"
"base": "^0.11.1",
"gulp-format-md": "^0.1.11",
"mocha": "^3.2.0"
},
"keywords": [
"api",
"app",
"application",
"async",
"base",
"baseplugin",
"building-blocks",
"create",
"engine",
"framework",
"helper",
"helpers",
"plugin",
"plugins",
"render",
"template",
"templates"
"templates",
"tool",
"toolkit",
"tools"
],

@@ -48,0 +59,0 @@ "verb": {

@@ -12,2 +12,3 @@ 'use strict';

require('isobject', 'isObject');
require('define-property', 'define');

@@ -30,3 +31,19 @@ require('is-valid-app');

};
/**
* Return true if the given value is a helper "group"
*/
utils.isHelperGroup = function(helpers) {
if (!helpers) return false;
if (typeof helpers === 'function' || utils.isObject(helpers)) {
var len = Object.keys(helpers).length;
var min = helpers.async ? 1 : 0;
return helpers.isGroup === true || len > min;
}
if (Array.isArray(helpers)) {
return helpers.isGroup === true;
}
return false;
};
/**

@@ -33,0 +50,0 @@ * Arrayify the given value by casting it to an array.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc