reduce-function-call

WebJar for reduce-function-call

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

reduce-function-call
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

reduce-function-call
WebJar for reduce-function-call
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/MoOx/reduce-function-call

Download reduce-function-call

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/reduce-function-call/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>reduce-function-call</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/reduce-function-call/
implementation 'org.webjars.npm:reduce-function-call:1.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/reduce-function-call/
implementation ("org.webjars.npm:reduce-function-call:1.0.3")
'org.webjars.npm:reduce-function-call:jar:1.0.3'
<dependency org="org.webjars.npm" name="reduce-function-call" rev="1.0.3">
  <artifact name="reduce-function-call" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='reduce-function-call', version='1.0.3')
)
libraryDependencies += "org.webjars.npm" % "reduce-function-call" % "1.0.3"
[org.webjars.npm/reduce-function-call "1.0.3"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : balanced-match jar [1.0.0,2)

Project Modules

There are no modules declared in this project.

reduce-function-call Build Status

Reduce function calls in a string, using a callback


Professionally supported reduce-function-call is now available


Installation

npm install reduce-function-call

Usage

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.

Contributing

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

Changelog

License


Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Versions

Version
1.0.3
1.0.2