{"id":23050244,"url":"https://github.com/krivega/repeated-calls","last_synced_at":"2025-08-15T03:31:19.978Z","repository":{"id":42923452,"uuid":"244579853","full_name":"Krivega/repeated-calls","owner":"Krivega","description":"Repeated calls to the function","archived":false,"fork":false,"pushed_at":"2024-10-07T16:27:23.000Z","size":516,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-12T04:19:33.444Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/Krivega.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2020-03-03T08:21:33.000Z","updated_at":"2024-10-07T16:27:27.000Z","dependencies_parsed_at":"2024-05-19T17:24:32.192Z","dependency_job_id":"d4bbd6f0-865e-489a-b837-b195841af0fc","html_url":"https://github.com/Krivega/repeated-calls","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"b6a4042eefefaad19b146b5c33d7896f2219d0c7"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Frepeated-calls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Frepeated-calls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Frepeated-calls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Frepeated-calls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Krivega","download_url":"https://codeload.github.com/Krivega/repeated-calls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229890136,"owners_count":18140041,"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-12-15T23:30:44.085Z","updated_at":"2024-12-15T23:30:44.661Z","avatar_url":"https://github.com/Krivega.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# repeated-calls\n\nRepeated calls to the function\n\n[![npm](https://img.shields.io/npm/v/repeated-calls?style=flat-square)](https://www.npmjs.com/package/repeated-calls)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/repeated-calls?style=flat-square)\n\nA stack of tasks that are executed one by one, but the result is taken from the last.\nIdentical functions on the stack (check by reference) are executed only once.\n\n## Install\n\nnpm\n\n```sh\nnpm install repeated-calls\n```\n\nyarn\n\n```sh\nyarn add repeated-calls\n```\n\n## Usage\n\n```js\nimport repeatedCalls from 'repeated-calls';\n\nconst targetFunction = function innerTargetFunction() {\n  innerTargetFunction.count = innerTargetFunction.count || 0;\n\n  innerTargetFunction.count += 1;\n\n  return innerTargetFunction.count;\n};\nconst isComplete = (callCount) =\u003e callCount === 3;\n\nreturn repeatedCalls({ targetFunction, isComplete }).then((callCount) =\u003e {\n  console.log(callCount); // 3\n});\n```\n\n### Complete if the limit is reached\n\n```js\nimport repeatedCalls from 'repeated-calls';\n\nconst targetFunction = function innerTargetFunction() {\n  innerTargetFunction.count = innerTargetFunction.count || 0;\n\n  innerTargetFunction.count += 1;\n\n  return innerTargetFunction.count;\n};\nconst isComplete = (callCount) =\u003e callCount === 3;\nconst callLimit = 3;\n\nreturn repeatedCalls({ targetFunction, isComplete, callLimit }).catch((error) =\u003e {\n  console.log(error); // call limit (3) is reached\n});\n```\n\n### Use async targetFunction\n\n```js\nimport { repeatedCallsAsync } from 'repeated-calls';\n\nconst targetFunction = function innerTargetFunction() {\n  innerTargetFunction.count = innerTargetFunction.count || 0;\n\n  innerTargetFunction.count += 1;\n\n  return Promise.resolve(innerTargetFunction.count);\n};\nconst isComplete = (callCount) =\u003e callCount === 3;\n\nreturn repeatedCalls({ targetFunction, isComplete }).then((callCount) =\u003e {\n  console.log(callCount); // 3\n});\n```\n\n## Run tests\n\n```sh\nnpm test\n```\n\n## Maintainer\n\n**Krivega Dmitriy**\n\n- Website: \u003chttps://krivega.com\u003e\n- Github: [@Krivega](https://github.com/Krivega)\n\n## Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/Krivega/repeated-calls/issues). You can also take a look at the [contributing guide](https://github.com/Krivega/repeated-calls/blob/master/CONTRIBUTING.md).\n\n## 📝 License\n\nCopyright © 2020 [Krivega Dmitriy](https://github.com/Krivega).\u003cbr /\u003e\nThis project is [MIT](https://github.com/Krivega/repeated-calls/blob/master/LICENSE) licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrivega%2Frepeated-calls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrivega%2Frepeated-calls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrivega%2Frepeated-calls/lists"}