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

jsexp

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsexp - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

4

exec.js

@@ -5,3 +5,3 @@ 'use strict';

isValidCondition = _require.isValidCondition,
replaceVariable = _require.replaceVariable,
getVariableValue = _require.getVariableValue,
callExpression = _require.callExpression;

@@ -22,3 +22,3 @@

} else {
value.push(replaceVariable(expression[i], context));
value.push(getVariableValue(expression[i], context));
}

@@ -25,0 +25,0 @@

{
"name": "jsexp",
"version": "0.1.4",
"version": "0.1.5",
"license": "MIT",

@@ -5,0 +5,0 @@ "scripts": {

@@ -7,3 +7,3 @@ 'use strict';

isValidCondition = _require.isValidCondition,
replaceVariable = _require.replaceVariable;
getVariableValue = _require.getVariableValue;
/**

@@ -30,3 +30,3 @@ * 数组转字符串

} else {
var replacedValue = replaceVariable(expression[i], context);
var replacedValue = getVariableValue(expression[i], context);
value.push(typeof replacedValue === 'string' ? "'".concat(replacedValue, "'") : replacedValue);

@@ -33,0 +33,0 @@ }

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

var rVariable = /^@(.+)/;
var rDeepPath = /^\d+\./;

@@ -33,4 +34,10 @@ function isValidCondition(expression) {

}
/**
* @param variable {string}
* @param context {object|array}
* @returns {string|*}
*/
function replaceVariable(variable, context) {
function getVariableValue(variable, context) {
if (context && typeof variable === 'string' && rVariable.test(variable)) {

@@ -40,4 +47,4 @@ var key = variable.substr(1);

if (Array.isArray(context)) {
for (var i = 0; i < context.length; i++) {
var value = get(context[i], key);
if (rDeepPath.test(key)) {
var value = get(context, key);

@@ -47,2 +54,10 @@ if (value !== undefined) {

}
} else {
for (var i = context.length - 1; i >= 0; i--) {
var _value = get(context[i], key);
if (_value !== undefined) {
return _value;
}
}
}

@@ -67,4 +82,4 @@ } else {

isValidCondition: isValidCondition,
replaceVariable: replaceVariable,
getVariableValue: getVariableValue,
callExpression: callExpression
};
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