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

benchpressjs

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

benchpressjs - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

build/benchpress.min.js

@@ -1,3 +0,3 @@

/*! benchpressjs by psychobunny, built on 2017-09-23 */
/*! benchpressjs by psychobunny, built on 2017-10-22 */
!function(e){"function"==typeof define&&define.amd&&define("benchpress",e)}(function(){function e(e){return new Promise(function(n,t){var o=r.loader(e,function(e){n(e)});o&&o.then&&o.then(n,t)})}function n(n,o,u){return o=r.addGlobals(o||{}),Promise.try(function(){return r.cache[n]=r.cache[n]||e(n),r.cache[n]}).then(function(e){return u&&(e=e.blocks&&e.blocks[u]),e?t(r.helpers,o,e):""})}var t=function(){"use strict";function e(e){return null==e||Array.isArray(e)&&0===e.length?"":e}function n(e,n){if(!e||"object"!=typeof e)return"";for(var t="",r=Object.keys(e),o=r.length,u=0;u<o;u+=1)t+=n(r[u],u,o);return t}function t(e,n,t,r){if("function"!=typeof n[t])return"";try{return n[t].apply(e,r)||""}catch(e){return""}}return"function"!=typeof Promise.try&&(Promise.try={try:function(e){return new Promise(function(n){return n(e())})}}.try),function(r,o,u){return u(r,o,e,n,t)}}(),r="object"==typeof module&&module.exports?module.exports:{};r.runtime=t,r.helpers={},r.registerHelper=function(e,n){r.helpers[e]=n};var o=(Object.freeze||function(e){return e})({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;","=":"&#x3D;"}),u=function(e){return o[e]},c=/[&<>"'`=]/g;r.registerHelper("__escape",function(e){return null==e?"":e?e.toString().replace(c,u):String(e)}),r.cache={},r.globals={},r.setGlobal=function(e,n){r.globals[e]=n};var i=Object.assign||jQuery.extend;return r.addGlobals=function(e){return i({},r.globals,e)},r.flush=function(){r.cache={}},r.render=n,r.parse=function(e,t,r,o){if(o||"object"!=typeof t||"function"!=typeof r||(o=r,r=t,t=null),"function"!=typeof o)throw TypeError("Invalid Arguments: callback must be a function");e?n(e,r,t).then(function(e){return setTimeout(o,0,e)},function(e){return console.error(e)}):o("")},r.registerLoader=function(e){r.loader=e},r});
'use strict';
const { Close } = require('./tokens');
const { Close } = require('./tokens').tokens;
const paths = require('./paths');

@@ -5,0 +5,0 @@

'use strict';
const tokens = require('./tokens');
const tokens = require('./tokens').tokens;

@@ -5,0 +5,0 @@ const { Text } = tokens;

@@ -18,9 +18,2 @@ 'use strict';

class StringLiteral extends Token {
constructor(value) {
super();
this.value = value;
}
}
class Expression extends Token {

@@ -45,2 +38,27 @@ constructor(value) {

Expression.extensions = [];
const unescapeMap = Object.freeze({
'\\b': '\b',
'\\t': '\t',
'\\n': '\n',
'\\v': '\v',
'\\f': '\f',
'\\r': '\r',
'\\"': '"',
'\\\'': '\'',
'\\\\': '\\'
});
class StringLiteral extends Token {
constructor(raw, rawValue) {
super();
const value = rawValue.replace(/\\(.)/g, (str, c) => unescapeMap[str] || c);
Object.assign(this, { raw, rawValue, value });
}
}
StringLiteral.pattern = '"((?:\\\\.|[^"\\n])*)"';
Expression.extensions.push(StringLiteral);
class SimpleExpression extends Token {

@@ -55,15 +73,39 @@ constructor(path) {

SimpleExpression.pattern = '[@a-zA-Z0-9/._:\\-]+';
Expression.extensions.push(SimpleExpression);
/**
* Split on commas, but ignore commas inside strings
* @param {string} str
*/
function splitArgs(str) {
const out = [];
let inString = false;
let currentArg = '';
for (let index = 0; index < str.length; index += 1) {
const c = str[index];
if (c === ',' && !inString) {
out.push(currentArg.trim());
currentArg = '';
} else if (currentArg.length === 0 && c === '"' && !inString) {
currentArg += c;
inString = true;
} else if (inString && c === '"' && str[index - 1] !== '\\') {
currentArg += c;
inString = false;
} else if (!(c === ' ' && currentArg.length === 0)) {
currentArg += c;
}
}
out.push(currentArg.trim());
return out;
}
exports.splitArgs = splitArgs;
class HelperExpression extends Token {
constructor(raw, helperName, args) {
super();
const arr = args.split(/\s*,\s*/).map(arg => {
const stringPattern = /^"(.*)"$/;
const matches = arg.match(stringPattern);
if (matches) {
return new StringLiteral(matches[1]);
}
return new Expression(arg);
});
const arr = splitArgs(args).slice(1).map(arg => new Expression(arg));
Object.assign(this, { raw, helperName, args: arr });

@@ -74,4 +116,4 @@ }

HelperExpression.pattern = `function\\.(${SimpleExpression.pattern})(?:\\s*,\\s*)?` + '([@a-zA-Z0-9/._: ,\\-"]+[@a-zA-Z0-9/_:\\-"]*)';
Expression.extensions.push(HelperExpression, SimpleExpression);
HelperExpression.pattern = `function\\.(${SimpleExpression.pattern})` + `((?: *, *(?:${StringLiteral.pattern}|${SimpleExpression.pattern}))*)`;
Expression.extensions.push(HelperExpression);

@@ -152,3 +194,3 @@ class OpenIf extends Token {

module.exports = tokens;
exports.tokens = tokens;
//# sourceMappingURL=tokens.js.map
'use strict';
const { Close } = require('./tokens');
const { Close } = require('./tokens').tokens;
const paths = require('./paths');

@@ -5,0 +5,0 @@

'use strict';
const tokens = require('./tokens');
const tokens = require('./tokens').tokens;

@@ -5,0 +5,0 @@ const { Text } = tokens;

@@ -18,9 +18,2 @@ 'use strict';

class StringLiteral extends Token {
constructor(value) {
super();
this.value = value;
}
}
class Expression extends Token {

@@ -48,2 +41,27 @@ constructor(value) {

const unescapeMap = Object.freeze({
'\\b': '\b',
'\\t': '\t',
'\\n': '\n',
'\\v': '\v',
'\\f': '\f',
'\\r': '\r',
'\\"': '"',
'\\\'': '\'',
'\\\\': '\\',
});
class StringLiteral extends Token {
constructor(raw, rawValue) {
super();
const value = rawValue.replace(/\\(.)/g, (str, c) => unescapeMap[str] || c);
Object.assign(this, { raw, rawValue, value });
}
static pattern = '"((?:\\\\.|[^"\\n])*)"';
}
Expression.extensions.push(StringLiteral);
class SimpleExpression extends Token {

@@ -58,23 +76,47 @@ constructor(path) {

Expression.extensions.push(SimpleExpression);
/**
* Split on commas, but ignore commas inside strings
* @param {string} str
*/
function splitArgs(str) {
const out = [];
let inString = false;
let currentArg = '';
for (let index = 0; index < str.length; index += 1) {
const c = str[index];
if (c === ',' && !inString) {
out.push(currentArg.trim());
currentArg = '';
} else if (currentArg.length === 0 && c === '"' && !inString) {
currentArg += c;
inString = true;
} else if (inString && c === '"' && str[index - 1] !== '\\') {
currentArg += c;
inString = false;
} else if (!(c === ' ' && currentArg.length === 0)) {
currentArg += c;
}
}
out.push(currentArg.trim());
return out;
}
exports.splitArgs = splitArgs;
class HelperExpression extends Token {
constructor(raw, helperName, args) {
super();
const arr = args.split(/\s*,\s*/).map((arg) => {
const stringPattern = /^"(.*)"$/;
const matches = arg.match(stringPattern);
if (matches) {
return new StringLiteral(matches[1]);
}
return new Expression(arg);
});
const arr = splitArgs(args).slice(1).map(arg => new Expression(arg));
Object.assign(this, { raw, helperName, args: arr });
}
static pattern = `function\\.(${SimpleExpression.pattern})(?:\\s*,\\s*)?`
+ '([@a-zA-Z0-9/._: ,\\-"]+[@a-zA-Z0-9/_:\\-"]*)';
static pattern = `function\\.(${SimpleExpression.pattern})`
+ `((?: *, *(?:${StringLiteral.pattern}|${SimpleExpression.pattern}))*)`;
}
Expression.extensions.push(HelperExpression, SimpleExpression);
Expression.extensions.push(HelperExpression);

@@ -168,2 +210,2 @@ class OpenIf extends Token {

module.exports = tokens;
exports.tokens = tokens;
{
"name": "benchpressjs",
"version": "1.1.0",
"version": "1.1.1",
"author": "psychobunny <psycho.bunny@hotmail.com>",

@@ -5,0 +5,0 @@ "description": "An ultralight and super fast templating framework",

'use strict';
module.exports = require('./build/lib/compiler/tokens');
module.exports = require('./build/lib/compiler/tokens').tokens;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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