{"id":18257902,"url":"https://github.com/linkdd/arecursion-js","last_synced_at":"2025-08-07T15:32:51.042Z","repository":{"id":42676322,"uuid":"323154556","full_name":"linkdd/arecursion-js","owner":"linkdd","description":"Asynchronous recursion without maximum depth","archived":false,"fork":false,"pushed_at":"2023-03-05T18:04:43.000Z","size":259,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T18:46:21.808Z","etag":null,"topics":["async","javascript","recursion"],"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/linkdd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-12-20T20:02:39.000Z","updated_at":"2021-06-12T14:51:16.000Z","dependencies_parsed_at":"2024-11-05T10:56:30.784Z","dependency_job_id":null,"html_url":"https://github.com/linkdd/arecursion-js","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Farecursion-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Farecursion-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Farecursion-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkdd%2Farecursion-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkdd","download_url":"https://codeload.github.com/linkdd/arecursion-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247941719,"owners_count":21022037,"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":["async","javascript","recursion"],"created_at":"2024-11-05T10:28:06.645Z","updated_at":"2025-04-08T22:46:47.718Z","avatar_url":"https://github.com/linkdd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eAsynchronous Recursion without Maximum Depth\u003c/h1\u003e\n\n## :alembic: How does it work ?\n\nThanks to the `setImmediate` function, the next iteration of the recursion is\nscheduled on the next frame of the event-loop.\n\nThe current iteration will return, removing the function from the call stack.\n\nThe whole recursion is wrapped in a promise that will resolve to the result of\nyour recursive function\n\n## :package: Installation\n\n```\n$ yarn add arecursion-js\n```\n\n## :wrench: Usage\n\n```javascript\nconst recursion = require('arecursion-js')\n\nconst factorial = recursion.doAsync((n, acc) =\u003e {\n    if (typeof acc === 'undefined') {\n        acc = 1\n    }\n\n    if (n \u003e 1) {\n        return recursion.iterate(n - 1, acc * n)\n    }\n    else {\n        return recursion.end(acc)\n    }\n})\n\nconst main = async () =\u003e {\n    console.log(await factorial(5))\n}\n\nmain()\n```\n\nOr with an asynchronous function:\n\n```javascript\nconst recursion = require('arecursion-js')\n\nconst slow_sum = recursion.doAsync(async (n, acc) =\u003e {\n    if (typeof acc === 'undefined') {\n        acc = 0\n    }\n\n    await some_slow_task()\n\n    if (n \u003e 1) {\n        return recursion.iterate(n - 1, acc + n)\n    }\n    else {\n        return recursion.end(acc)\n    }\n})\n\nconst main = async () =\u003e {\n    console.log(await slow_sum(5))\n}\n\nmain()\n```\n\n## :memo: License\n\nThis package is released under the terms of the [MIT License](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdd%2Farecursion-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkdd%2Farecursion-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkdd%2Farecursion-js/lists"}