{"id":17497167,"url":"https://github.com/moox/reduce-function-call","last_synced_at":"2025-09-11T11:31:03.989Z","repository":{"id":19427792,"uuid":"22670539","full_name":"MoOx/reduce-function-call","owner":"MoOx","description":"Reduce function calls in a string, using a callback","archived":false,"fork":false,"pushed_at":"2024-07-03T13:55:05.000Z","size":92,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-31T11:26:18.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MoOx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"tidelift":"npm/reduce-function-call","ko_fi":"moox__","custom":"https://www.paypal.me/MoOx"}},"created_at":"2014-08-06T05:16:49.000Z","updated_at":"2024-07-03T13:55:06.000Z","dependencies_parsed_at":"2024-10-20T14:37:09.861Z","dependency_job_id":null,"html_url":"https://github.com/MoOx/reduce-function-call","commit_stats":{"total_commits":27,"total_committers":7,"mean_commits":3.857142857142857,"dds":0.6296296296296297,"last_synced_commit":"e73546e1915e9b9c220e5ed40866f3df125f6c2f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Freduce-function-call","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Freduce-function-call/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Freduce-function-call/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Freduce-function-call/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MoOx","download_url":"https://codeload.github.com/MoOx/reduce-function-call/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232641223,"owners_count":18554527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-19T15:15:22.925Z","updated_at":"2025-01-05T21:03:42.869Z","avatar_url":"https://github.com/MoOx.png","language":"JavaScript","funding_links":["https://tidelift.com/funding/github/npm/reduce-function-call","https://ko-fi.com/moox__","https://www.paypal.me/MoOx","https://tidelift.com/subscription/pkg/npm-reduce-function-call?utm_source=npm-reduce-function-call\u0026utm_medium=referral\u0026utm_campaign=readme","https://tidelift.com/security"],"categories":[],"sub_categories":[],"readme":"# reduce-function-call [![Build Status](https://travis-ci.org/MoOx/reduce-function-call.svg?branch=master)](https://travis-ci.org/MoOx/reduce-function-call)\n\n\u003e Reduce function calls in a string, using a callback\n\n---\n\n[Professionally supported reduce-function-call is now available](https://tidelift.com/subscription/pkg/npm-reduce-function-call?utm_source=npm-reduce-function-call\u0026utm_medium=referral\u0026utm_campaign=readme)\n\n---\n\n## Installation\n\n```console\nnpm install reduce-function-call\n```\n\n## Usage\n\n```js\nvar reduceFunctionCall = require(\"reduce-function-call\")\n\nreduceFunctionCall(\"foo(1)\", \"foo\", function(body) {\n  // body === \"1\"\n  return parseInt(body, 10) + 1\n})\n// \"2\"\n\nvar nothingOrUpper = function(body, functionIdentifier) {\n  // ignore empty value\n  if (body === \"\") {\n    return functionIdentifier + \"()\"\n  }\n\n  return body.toUpperCase()\n}\n\nreduceFunctionCall(\"bar()\", \"bar\", nothingOrUpper)\n// \"bar()\"\n\nreduceFunctionCall(\"upper(baz)\", \"upper\", nothingOrUpper)\n// \"BAZ\"\n\nreduceFunctionCall(\"math(math(2 + 2) * 4 + math(2 + 2)) and other things\", \"math\", function(body, functionIdentifier, call) {\n  try {\n    return eval(body)\n  }\n  catch (e) {\n    return call\n  }\n})\n// \"20 and other things\"\n\nreduceFunctionCall(\"sha bla blah() blaa bla() abla() aabla() blaaa()\", /\\b([a-z]?bla[a-z]?)\\(/, function(body, functionIdentifier) {\n  if (functionIdentifier === \"bla\") {\n    return \"ABRACADABRA\"\n  }\n  return functionIdentifier.replace(\"bla\", \"!\")\n}\n// \"sha bla !h blaa ABRACADABRA a! aabla() blaaa()\"\n```\n\nSee [unit tests](test/index.js) for others examples.\n\n## Contributing\n\nWork on a branch, install dev-dependencies, respect coding style \u0026 run tests before submitting a bug fix or a feature.\n\n```console\ngit clone https://github.com/MoOx/reduce-function-call.git\ngit checkout -b patch-1\nnpm install\nnpm test\n```\n\n---\n\n## [Changelog](CHANGELOG.md)\n\n## [License](LICENSE)\n\n---\n\n## Security contact information\n\nTo report a security vulnerability, please use the\n[Tidelift security contact](https://tidelift.com/security). Tidelift will\ncoordinate the fix and disclosure.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoox%2Freduce-function-call","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoox%2Freduce-function-call","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoox%2Freduce-function-call/lists"}