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

jsexpr

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

jsexpr - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

2

dist/browser/jsexpr.js

@@ -50,3 +50,3 @@ "use strict";

var RX_RPL_PARSE = new RegExp("\\" + token + "\\{([^\\}]+)\\}"); // /\$\{([^\}]+)\}/;
var RX_RPL_TOKEN = new RegExp("\\" + token + "\\{|\\}"); // /\$\{|\}/g;
var RX_RPL_TOKEN = new RegExp("\\" + token + "\\{|\\}", 'g'); // /\$\{|\}/g;
var CACHE = {};

@@ -53,0 +53,0 @@

/*! jsexpr 2019-09-23 */
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function u(i,f,c){function a(n,t){if(!f[n]){if(!i[n]){var r="function"==typeof require&&require;if(!t&&r)return r(n,!0);if(l)return l(n,!0);var e=new Error("Cannot find module '"+n+"'");throw e.code="MODULE_NOT_FOUND",e}var o=f[n]={exports:{}};i[n][0].call(o.exports,function(t){return a(i[n][1][t]||t)},o,o.exports,u,i,f,c)}return f[n].exports}for(var l="function"==typeof require&&require,t=0;t<c.length;t++)a(c[t]);return a}({1:[function(n,r,e){(function(){this.jsexpr;var t=n("./index.js");void 0!==e&&(void 0!==r&&r.exports&&(e=r.exports=t),e.jsexpr=t),"undefined"!=typeof window&&(window.jsexpr=t)}).call(this)},{"./index.js":2}],2:[function(t,n,r){var e=t("./lib");n.exports=e},{"./lib":4}],3:[function(require,module,exports){var extend=require("extend");function instance(token){var RX=new RegExp("\\"+token+"\\{[^\\}]+\\}","g"),RX_RPL_PARSE=new RegExp("\\"+token+"\\{([^\\}]+)\\}"),RX_RPL_TOKEN=new RegExp("\\"+token+"\\{|\\}"),CACHE={};function cacheeval(obj,key){if(!CACHE[key]){var fn=eval("(function(){\n\t\t\t\treturn function() {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn this."+key+";\n\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn "+key+";\n\t\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})()");CACHE[key]=fn}return CACHE[key].call(obj)}function fneval(obj,key){try{return eval("this."+key)}catch(t){return}}function fnassign(path){return eval("(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj."+path+" = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()")}var EVALS={eval:function(t,n){var r=fneval.call(t,t,n);return void 0===r?"":r},iteval:function(n,t){t.split(".").forEach(function(t){null!=n&&null!=n&&(n=n[t])});var r=n||void 0;return void 0===r?"":r},ceval:function(t,n){var r=cacheeval(t,n);return void 0===r?"":r},valwalk:function(t,n,r){if(!t)return t;for(var e in t){var o=r+(r?".":"")+e,u=n[o];void 0!==u?t[e]=u:"object"==_typeof(t[e])&&EVALS.valwalk(t[e],n,o)}return t}};function parse(r,n){n=n||"ceval";var t=r.match(RX);t&&t.forEach(function(t){var n=t.replace(RX_RPL_PARSE,"$1").trim();r=r.replace(t,"__val(entry,'"+n+"')")});var e=new Function("entry","__val","return ("+r+")");return function(t){return e(t,EVALS[n])}}function tokens(o,u){if(u=EVALS[u||"ceval"],"${JSON}"==o)return function(t){return JSON.stringify(t,null,2)};var i,f=[];return(o.match(RX)||[]).forEach(function(t){var n=o.indexOf(t),r=o.substring(0,n),e=t.replace(RX_RPL_TOKEN,"");o=o.substring(n+t.length),f.push(r),f.push(function(t){return u(t,e)})}),f.push(o),f=f.filter(function(t){return""!=t}),1<(i=f.length)?function(t){for(var n="",r=0;r<i;r++){var e=f[r];n+="string"==typeof e?e:e(t)}return n}:function(t){var n=f[0];return"string"==typeof n?n:n(t)}}function jsontokens(o){var u,i=[];return function e(o,u){o&&Object.keys(o).forEach(function(t){var n=u+(u?".":"")+t,r=o[t];"string"==typeof r?i.push({path:n,fn:tokens(r)}):e(r,n)})}(o,""),u=i.length,function(t){for(var n={},r=0;r<u;r++){var e=i[r];n[e.path]=e.fn(t)}return EVALS.valwalk(extend(!0,{},o),n,"")}}function exprfn(n,t){return"number"==typeof n?function(t){return n}:"object"==(void 0===n?"undefined":_typeof(n))?jsontokens(n,t):tokens(n)}return{fn:parse,eval:parse,assign:fnassign,expr:exprfn,expression:exprfn}}module.exports=instance},{extend:5}],4:[function(t,n,r){var e=t("./expression"),o=e("$");o.newInstance=function(t){return e(t)},n.exports=o},{"./expression":3}],5:[function(t,n,r){var o=Object.prototype.hasOwnProperty,u=Object.prototype.toString,s=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===u.call(t)},p=function(t){if(!t||"[object Object]"!==u.call(t))return!1;var n,r=o.call(t,"constructor"),e=t.constructor&&t.constructor.prototype&&o.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!e)return!1;for(n in t);return void 0===n||o.call(t,n)};n.exports=function t(){var n,r,e,o,u,i,f=arguments[0],c=1,a=arguments.length,l=!1;for("boolean"==typeof f&&(l=f,f=arguments[1]||{},c=2),(null==f||"object"!==(void 0===f?"undefined":_typeof(f))&&"function"!=typeof f)&&(f={});c<a;++c)if(null!=(n=arguments[c]))for(r in n)e=f[r],f!==(o=n[r])&&(l&&o&&(p(o)||(u=s(o)))?(u?(u=!1,i=e&&s(e)?e:[]):i=e&&p(e)?e:{},f[r]=t(l,i,o)):void 0!==o&&(f[r]=o));return f}},{}]},{},[1]);
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function u(i,f,c){function a(n,t){if(!f[n]){if(!i[n]){var r="function"==typeof require&&require;if(!t&&r)return r(n,!0);if(l)return l(n,!0);var e=new Error("Cannot find module '"+n+"'");throw e.code="MODULE_NOT_FOUND",e}var o=f[n]={exports:{}};i[n][0].call(o.exports,function(t){return a(i[n][1][t]||t)},o,o.exports,u,i,f,c)}return f[n].exports}for(var l="function"==typeof require&&require,t=0;t<c.length;t++)a(c[t]);return a}({1:[function(n,r,e){(function(){this.jsexpr;var t=n("./index.js");void 0!==e&&(void 0!==r&&r.exports&&(e=r.exports=t),e.jsexpr=t),"undefined"!=typeof window&&(window.jsexpr=t)}).call(this)},{"./index.js":2}],2:[function(t,n,r){var e=t("./lib");n.exports=e},{"./lib":4}],3:[function(require,module,exports){var extend=require("extend");function instance(token){var RX=new RegExp("\\"+token+"\\{[^\\}]+\\}","g"),RX_RPL_PARSE=new RegExp("\\"+token+"\\{([^\\}]+)\\}"),RX_RPL_TOKEN=new RegExp("\\"+token+"\\{|\\}","g"),CACHE={};function cacheeval(obj,key){if(!CACHE[key]){var fn=eval("(function(){\n\t\t\t\treturn function() {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn this."+key+";\n\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn "+key+";\n\t\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})()");CACHE[key]=fn}return CACHE[key].call(obj)}function fneval(obj,key){try{return eval("this."+key)}catch(t){return}}function fnassign(path){return eval("(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj."+path+" = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()")}var EVALS={eval:function(t,n){var r=fneval.call(t,t,n);return void 0===r?"":r},iteval:function(n,t){t.split(".").forEach(function(t){null!=n&&null!=n&&(n=n[t])});var r=n||void 0;return void 0===r?"":r},ceval:function(t,n){var r=cacheeval(t,n);return void 0===r?"":r},valwalk:function(t,n,r){if(!t)return t;for(var e in t){var o=r+(r?".":"")+e,u=n[o];void 0!==u?t[e]=u:"object"==_typeof(t[e])&&EVALS.valwalk(t[e],n,o)}return t}};function parse(r,n){n=n||"ceval";var t=r.match(RX);t&&t.forEach(function(t){var n=t.replace(RX_RPL_PARSE,"$1").trim();r=r.replace(t,"__val(entry,'"+n+"')")});var e=new Function("entry","__val","return ("+r+")");return function(t){return e(t,EVALS[n])}}function tokens(o,u){if(u=EVALS[u||"ceval"],"${JSON}"==o)return function(t){return JSON.stringify(t,null,2)};var i,f=[];return(o.match(RX)||[]).forEach(function(t){var n=o.indexOf(t),r=o.substring(0,n),e=t.replace(RX_RPL_TOKEN,"");o=o.substring(n+t.length),f.push(r),f.push(function(t){return u(t,e)})}),f.push(o),f=f.filter(function(t){return""!=t}),1<(i=f.length)?function(t){for(var n="",r=0;r<i;r++){var e=f[r];n+="string"==typeof e?e:e(t)}return n}:function(t){var n=f[0];return"string"==typeof n?n:n(t)}}function jsontokens(o){var u,i=[];return function e(o,u){o&&Object.keys(o).forEach(function(t){var n=u+(u?".":"")+t,r=o[t];"string"==typeof r?i.push({path:n,fn:tokens(r)}):e(r,n)})}(o,""),u=i.length,function(t){for(var n={},r=0;r<u;r++){var e=i[r];n[e.path]=e.fn(t)}return EVALS.valwalk(extend(!0,{},o),n,"")}}function exprfn(n,t){return"number"==typeof n?function(t){return n}:"object"==(void 0===n?"undefined":_typeof(n))?jsontokens(n,t):tokens(n)}return{fn:parse,eval:parse,assign:fnassign,expr:exprfn,expression:exprfn}}module.exports=instance},{extend:5}],4:[function(t,n,r){var e=t("./expression"),o=e("$");o.newInstance=function(t){return e(t)},n.exports=o},{"./expression":3}],5:[function(t,n,r){var o=Object.prototype.hasOwnProperty,u=Object.prototype.toString,s=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===u.call(t)},p=function(t){if(!t||"[object Object]"!==u.call(t))return!1;var n,r=o.call(t,"constructor"),e=t.constructor&&t.constructor.prototype&&o.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!e)return!1;for(n in t);return void 0===n||o.call(t,n)};n.exports=function t(){var n,r,e,o,u,i,f=arguments[0],c=1,a=arguments.length,l=!1;for("boolean"==typeof f&&(l=f,f=arguments[1]||{},c=2),(null==f||"object"!==(void 0===f?"undefined":_typeof(f))&&"function"!=typeof f)&&(f={});c<a;++c)if(null!=(n=arguments[c]))for(r in n)e=f[r],f!==(o=n[r])&&(l&&o&&(p(o)||(u=s(o)))?(u?(u=!1,i=e&&s(e)?e:[]):i=e&&p(e)?e:{},f[r]=t(l,i,o)):void 0!==o&&(f[r]=o));return f}},{}]},{},[1]);

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -8,5 +8,5 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

function instance(token) {
var RX = new RegExp("\\" + token + "\\{[^\\}]+\\}", 'g'); // /\$\{[^\}]+\}/g;
var RX_RPL_PARSE = new RegExp("\\" + token + "\\{([^\\}]+)\\}"); // /\$\{([^\}]+)\}/;
var RX_RPL_TOKEN = new RegExp("\\" + token + "\\{|\\}"); // /\$\{|\}/g;
var RX = new RegExp('\\' + token + '\\{[^\\}]+\\}', 'g'); // /\$\{[^\}]+\}/g;
var RX_RPL_PARSE = new RegExp('\\' + token + '\\{([^\\}]+)\\}'); // /\$\{([^\}]+)\}/;
var RX_RPL_TOKEN = new RegExp('\\' + token + '\\{|\\}', 'g'); // /\$\{|\}/g;
var CACHE = {};

@@ -16,3 +16,3 @@

if (!CACHE[key]) {
var fn = eval("(function(){\n\t\t\t\treturn function() {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn this." + key + ";\n\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn " + key + ";\n\t\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})()");
var fn = eval('(function(){\n\t\t\t\treturn function() {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn this.' + key + ';\n\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn ' + key + ';\n\t\t\t\t\t\t}catch(err) {\n\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})()');
CACHE[key] = fn;

@@ -32,3 +32,3 @@ }

function fnassign(path) {
return eval("(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj." + path + " = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()");
return eval('(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj.' + path + ' = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()');
}

@@ -57,3 +57,3 @@

for (var k in src) {
var newpath = "" + path + (path ? '.' : '') + k;
var newpath = '' + path + (path ? '.' : '') + k;
var rop = ops[newpath];

@@ -131,3 +131,3 @@ if (rop !== undefined) src[k] = rop;else if (_typeof(src[k]) == "object") EVALS.valwalk(src[k], ops, newpath);

Object.keys(json).forEach(function (k) {
var newpath = "" + path + (path ? '.' : '') + k;
var newpath = '' + path + (path ? '.' : '') + k;
var t = json[k];

@@ -160,3 +160,3 @@ if (typeof t == "string") {

};
} else if ((typeof input === "undefined" ? "undefined" : _typeof(input)) == "object") {
} else if ((typeof input === 'undefined' ? 'undefined' : _typeof(input)) == "object") {
return jsontokens(input, replace);

@@ -163,0 +163,0 @@ } else {

@@ -6,3 +6,3 @@ const extend = require("extend");

const RX_RPL_PARSE = new RegExp(`\\${token}\\{([^\\}]+)\\}`); // /\$\{([^\}]+)\}/;
const RX_RPL_TOKEN = new RegExp(`\\${token}\\{|\\}`); // /\$\{|\}/g;
const RX_RPL_TOKEN = new RegExp(`\\${token}\\{|\\}`,'g'); // /\$\{|\}/g;
const CACHE = {}

@@ -9,0 +9,0 @@

{
"name": "jsexpr",
"version": "0.6.0",
"version": "0.6.1",
"description": "String and JSON expression interpolator and evaluator. Interpolates or evaluates a string against a json object, or transforms an object into another based on a json template",

@@ -5,0 +5,0 @@ "main": "dist/node/index.js",

@@ -68,2 +68,3 @@ const

describe(`String interpolation (${mode})`, function() {
debugger;
let fn1 = expression.expr('(${a} + ${b}) / ${c} + ${d.e}',mode);

@@ -70,0 +71,0 @@ let fn2 = expression.expr('${a} < ${d.e}',mode);

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