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

reduce-function-call

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reduce-function-call - npm Package Compare versions

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": [

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