Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/reduce-function-call/ |
Upload File : |
# reduce-function-call [](https://travis-ci.org/MoOx/reduce-function-call) > Reduce function calls in a string, using a callback --- [Professionally supported reduce-function-call is now available](https://tidelift.com/subscription/pkg/npm-reduce-function-call?utm_source=npm-reduce-function-call&utm_medium=referral&utm_campaign=readme) --- ## Installation ```console npm install reduce-function-call ``` ## Usage ```js 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](test/index.js) for others examples. ## Contributing Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature. ```console git clone https://github.com/MoOx/reduce-function-call.git git checkout -b patch-1 npm install npm test ``` --- ## [Changelog](CHANGELOG.md) ## [License](LICENSE) --- ## Security contact information To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.