Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "jsexp", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "rollup --config build/config.js" | ||
"build": "rollup --config build/config.js", | ||
"publish": "npm run build && npm publish" | ||
}, | ||
@@ -8,0 +9,0 @@ "dependencies": { |
@@ -31,4 +31,12 @@ 'use strict'; | ||
function transform(expression) { | ||
function transform(expression, callback) { | ||
if (expression) { | ||
if (callback) { | ||
var expr = callback(expression); | ||
if (Array.isArray(expr) && rulesMapReverse[expr[0]]) { | ||
return expr; | ||
} | ||
} | ||
var type = expression.type; | ||
@@ -38,3 +46,3 @@ var originOperator = expression.operator; | ||
if (originOperator === '@') { | ||
var argument = transform(expression.argument); | ||
var argument = transform(expression.argument, callback); | ||
return isValidate(argument) ? "@".concat(argument) : undefined; | ||
@@ -46,8 +54,8 @@ } else if (type === LITERAL) { | ||
} else if (type === MEMBER_EXP) { | ||
var object = transform(expression.object); | ||
var property = transform(expression.property); | ||
var object = transform(expression.object, callback); | ||
var property = transform(expression.property, callback); | ||
return isValidate(object) && isValidate(property) ? "".concat(object, ".").concat(property) : undefined; | ||
} else if (type === ARRAY_EXP) { | ||
return expression.elements.map(function (item) { | ||
return transform(item); | ||
return transform(item, callback); | ||
}); | ||
@@ -59,8 +67,8 @@ } else { | ||
if (type === UNARY_EXP) { | ||
var _argument = transform(expression.argument); | ||
var _argument = transform(expression.argument, callback); | ||
return isValidate(_argument) ? [operator, _argument] : []; | ||
} else if (type === LOGICAL_EXP || type === BINARY_EXP) { | ||
var left = transform(expression.left); | ||
var right = transform(expression.right); | ||
var left = transform(expression.left, callback); | ||
var right = transform(expression.right, callback); | ||
return isValidate(left) && isValidate(right) ? [operator, left, right] : []; | ||
@@ -67,0 +75,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33794
1064