reduce-function-call
Advanced tools
Comparing version 1.0.0 to 1.0.1
18
index.js
@@ -20,6 +20,6 @@ /* | ||
function reduceFunctionCall(string, functionIdentifier, callback) { | ||
function reduceFunctionCall(string, functionRE, callback) { | ||
var call = string | ||
return getFunctionCalls(string, functionIdentifier).reduce(function(string, obj) { | ||
return string.replace(obj.functionIdentifier + "(" + obj.matches.body + ")", evalFunctionCall(obj.matches.body, obj.functionIdentifier, callback, call)) | ||
return getFunctionCalls(string, functionRE).reduce(function(string, obj) { | ||
return string.replace(obj.functionIdentifier + "(" + obj.matches.body + ")", evalFunctionCall(obj.matches.body, obj.functionIdentifier, callback, call, functionRE)) | ||
}, string) | ||
@@ -36,6 +36,6 @@ } | ||
function getFunctionCalls(call, functionIdentifier) { | ||
function getFunctionCalls(call, functionRE) { | ||
var expressions = [] | ||
var fnRE = typeof functionIdentifier === "string" ? new RegExp("\\b(" + functionIdentifier + ")\\(") : functionIdentifier | ||
var fnRE = typeof functionRE === "string" ? new RegExp("\\b(" + functionRE + ")\\(") : functionRE | ||
do { | ||
@@ -47,3 +47,3 @@ var searchMatch = fnRE.exec(call) | ||
if (searchMatch[1] === undefined) { | ||
throw new Error("Missing the first couple of parenthesis to get the function identifier in " + functionIdentifier) | ||
throw new Error("Missing the first couple of parenthesis to get the function identifier in " + functionRE) | ||
} | ||
@@ -55,3 +55,3 @@ var fn = searchMatch[1] | ||
if (!matches) { | ||
throw new SyntaxError(functionIdentifier + "(): missing closing ')' in the value '" + call + "'") | ||
throw new SyntaxError(fn + "(): missing closing ')' in the value '" + call + "'") | ||
} | ||
@@ -75,5 +75,5 @@ | ||
function evalFunctionCall (string, functionIdentifier, callback, call) { | ||
function evalFunctionCall (string, functionIdentifier, callback, call, functionRE) { | ||
// allow recursivity | ||
return callback(reduceFunctionCall(string, functionIdentifier, callback), functionIdentifier, call) | ||
return callback(reduceFunctionCall(string, functionRE, callback), functionIdentifier, call) | ||
} |
{ | ||
"name": "reduce-function-call", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Reduce function calls in a string, using a callback", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
5603