{"id":16487425,"url":"https://github.com/tjenkinson/forkable-iterator","last_synced_at":"2025-10-07T06:48:30.606Z","repository":{"id":57896652,"uuid":"526536161","full_name":"tjenkinson/forkable-iterator","owner":"tjenkinson","description":"Make a JS Iterator forkable.","archived":false,"fork":false,"pushed_at":"2025-05-06T13:16:42.000Z","size":726,"stargazers_count":5,"open_issues_count":7,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-27T02:21:54.366Z","etag":null,"topics":["clone","fork","generator","iterable","iterator","tee"],"latest_commit_sha":null,"homepage":"","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/tjenkinson.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-08-19T09:05:07.000Z","updated_at":"2025-05-06T13:16:46.000Z","dependencies_parsed_at":"2024-04-22T23:43:49.897Z","dependency_job_id":"c99b8333-7a95-4cc2-b128-3dd7bc9c1151","html_url":"https://github.com/tjenkinson/forkable-iterator","commit_stats":{"total_commits":107,"total_committers":3,"mean_commits":"35.666666666666664","dds":"0.16822429906542058","last_synced_commit":"fd18f850d44c5b9116cc48debd8df15f9012d845"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tjenkinson/forkable-iterator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjenkinson%2Fforkable-iterator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjenkinson%2Fforkable-iterator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjenkinson%2Fforkable-iterator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjenkinson%2Fforkable-iterator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjenkinson","download_url":"https://codeload.github.com/tjenkinson/forkable-iterator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjenkinson%2Fforkable-iterator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278734424,"owners_count":26036404,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clone","fork","generator","iterable","iterator","tee"],"created_at":"2024-10-11T13:34:13.300Z","updated_at":"2025-10-07T06:48:30.584Z","avatar_url":"https://github.com/tjenkinson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# forkable-iterator\n\nMake a JS [`Iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#iterators) forkable.\n\nBe aware that if you have a fork that is not consuming values as it gets further and further behind more memory will be used. Make sure you `null` out references to forks that you no longer need to allow garbage collection to occur.\n\n## Installation\n\n```sh\nnpm install --save forkable-iterator\n```\n\nAlso available on JSDelivr at \"https://cdn.jsdelivr.net/npm/forkable-iterator@1\".\n\n## Usage\n\n```ts\nimport { buildForkableIterator, fork } from 'forkable-iterator';\n\nfunction* Source() {\n  yield 1;\n  yield 2;\n  return 'return';\n}\n\nconst forkableIterator = buildForkableIterator(source());\n\nconsole.log(forkableIterator.next()); // { value: 1, done: false }\n\nconst child1 = fork(forkableIterator);\n// { value: 2, done: false }\nconsole.log(child1.next());\n// { value: 2, done: false }\nconsole.log(forkableIterator.next());\n\n// { value: 'return', done: true }\nconsole.log(child1.next());\n// { value: 'return', done: true }\nconsole.log(forkableIterator.next());\n```\n\n## API\n\n### `buildForkableIterator(source)`\n\nReturns a `ForkableIterator` from the provided `source` iterator, which has the same API as `Iterator`, but can be forked.\n\nTo create a fork use the exported [`fork(forkableIterator)`](#forkforkableiterator) function.\n\nThe source iterator must not be read from directly as any forks will miss the values.\n\nThe returned `ForkableIterator` will not implement `return()` or `throw()` functions.\n\n### `fork(forkableIterator)`\n\nCreate a fork of the provided `ForkableIterator` at the current point.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjenkinson%2Fforkable-iterator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjenkinson%2Fforkable-iterator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjenkinson%2Fforkable-iterator/lists"}