Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
reduce-function-call
Advanced tools
Readme
Reduce function calls in a string, using a callback
Professionally supported reduce-function-call is now available
npm install reduce-function-call
var reduceFunctionCall = require("reduce-function-call")
reduceFunctionCall("foo(1)", "foo", function(body) {
// body === "1"
return parseInt(body, 10) + 1
})
// "2"
var nothingOrUpper = function(body, functionIdentifier) {
// ignore empty value
if (body === "") {
return functionIdentifier + "()"
}
return body.toUpperCase()
}
reduceFunctionCall("bar()", "bar", nothingOrUpper)
// "bar()"
reduceFunctionCall("upper(baz)", "upper", nothingOrUpper)
// "BAZ"
reduceFunctionCall("math(math(2 + 2) * 4 + math(2 + 2)) and other things", "math", function(body, functionIdentifier, call) {
try {
return eval(body)
}
catch (e) {
return call
}
})
// "20 and other things"
reduceFunctionCall("sha bla blah() blaa bla() abla() aabla() blaaa()", /\b([a-z]?bla[a-z]?)\(/, function(body, functionIdentifier) {
if (functionIdentifier === "bla") {
return "ABRACADABRA"
}
return functionIdentifier.replace("bla", "!")
}
// "sha bla !h blaa ABRACADABRA a! aabla() blaaa()"
See unit tests for others examples.
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
git clone https://github.com/MoOx/reduce-function-call.git
git checkout -b patch-1
npm install
npm test
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
FAQs
Reduce function calls in a string, using a callback
The npm package reduce-function-call receives a total of 1,025,467 weekly downloads. As such, reduce-function-call popularity was classified as popular.
We found that reduce-function-call demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.