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

async-helpers

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-helpers - npm Package Compare versions

Comparing version 0.3.10 to 0.3.11

85

index.js

@@ -44,12 +44,3 @@ /*!

this.counter = 0;
Object.defineProperty(this, 'prefixRegx', {
configurable: true,
set: function(regex) {
define(this, '_re', regex);
},
get: function() {
return this._re || (this._re = toRegex(this.prefix, 'g'));
}
});
this.prefixRegex = toRegex(this.prefix);
}

@@ -139,7 +130,10 @@

AsyncHelpers.prototype.wrapHelper = function(helper, options) {
if (isObject(helper)) {
if (isObject(helper) && typeof options === 'undefined') {
options = helper;
helper = null;
helper = this.helpers;
}
options = options || {};
helper = helper || this.helpers;
var type = typeOf(helper);

@@ -153,11 +147,6 @@ switch (type) {

if (isHelperGroup(helper)) {
helper = this.wrapHelpers(helper, options);
return this.wrapHelpers(helper, options);
}
if (helper.wrapped === true) {
return helper;
}
var opts = extend({}, this.options, options);
if (opts.wrap) {
if (options.wrap && helper.wrapped !== true) {
return this.wrapper(helper, helper, this);

@@ -261,3 +250,16 @@ }

AsyncHelpers.prototype.matches = function(str) {
return str.match(this.prefixRegx);
if (typeof str !== 'string') {
throw new TypeError('AsyncHelpers#matches expects a string');
}
var matches = [];
var match;
var input = str;
while ((match = this.prefixRegex.exec(input))) {
matches.push(match[0]);
input = input.slice(match.index + match[0].length);
}
return matches;
};

@@ -271,3 +273,6 @@

AsyncHelpers.prototype.hasAsyncId = function(str) {
return this.prefixRegx.test(str);
if (typeof str !== 'string') {
throw new TypeError('AsyncHelpers#hasAsyncId expects a string');
}
return str.indexOf(this.prefix) !== -1;
};

@@ -331,6 +336,7 @@

if (self.hasAsyncId(result)) {
if (typeof result === 'string' && self.hasAsyncId(result)) {
self.resolveIds(result, next);
return;
}
next(null, result);

@@ -345,3 +351,3 @@ return;

str = helper.fn.apply(helper.context, args);
if (self.hasAsyncId(str)) {
if (typeof str === 'string' && self.hasAsyncId(str)) {
self.resolveIds(str, next);

@@ -456,2 +462,7 @@ return;

var val = yield self.resolveId(key);
if (typeof val !== 'string') {
throw new TypeError('AsyncHelpers#resolveIds expected val to be a string');
}
str = str.split(key).join(val);

@@ -526,14 +537,8 @@ }

function toRegex(prefix, flags, options) {
var key = appendPrefix(prefix, '(\\d)+');
function toRegex(prefix) {
var key = appendPrefix(prefix, '(\\d+)');
if (cache.hasOwnProperty(key)) {
return cache[key];
}
if (typeof flags !== 'string') {
options = flags;
flags = undefined;
}
var regex = new RegExp(createRegexString(key, options), flags);
var regex = new RegExp(createRegexString(key));
cache[key] = regex;

@@ -549,3 +554,3 @@ return regex;

function createRegexString(prefix, options) {
function createRegexString(prefix) {
var key = 'createRegexString:' + prefix;

@@ -555,7 +560,3 @@ if (cache.hasOwnProperty(key)) {

}
options = options || {};
var str = '\\' + prefix.split(/\\?\$/).join('\\$') + '(\\d)+\\$\\}';
if (options.strict) {
str = '^' + str + '$';
}
var str = (prefix + '(\\d+)$}').replace(/\\?([${}])/g, '\\$1');
cache[key] = str;

@@ -571,10 +572,10 @@ return str;

if (!helpers) return false;
if (helpers.isGroup) {
return true;
}
if (typeof helpers === 'function' || isObject(helpers)) {
var len = Object.keys(helpers).length;
var min = (helpers.async || helpers.sync) ? 1 : 0;
return helpers.isGroup === true || len > min;
return len > min;
}
if (Array.isArray(helpers)) {
return helpers.isGroup === true;
}
return false;

@@ -581,0 +582,0 @@ }

{
"name": "async-helpers",
"description": "Use async helpers in templates with engines that typically only handle sync helpers. Handlebars and Lodash have been tested.",
"version": "0.3.10",
"version": "0.3.11",
"homepage": "https://github.com/doowb/async-helpers",

@@ -6,0 +6,0 @@ "author": "Brian Woodward (https://github.com/doowb)",

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