{"id":15823458,"url":"https://github.com/3shain/multishot-generator","last_synced_at":"2025-08-13T05:03:22.575Z","repository":{"id":208945123,"uuid":"722857877","full_name":"3Shain/multishot-generator","owner":"3Shain","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-26T05:19:55.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-11T02:43:53.077Z","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/3Shain.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,"publiccode":null,"codemeta":null}},"created_at":"2023-11-24T05:50:45.000Z","updated_at":"2025-03-30T00:51:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ab23835-0828-46c9-9247-d84d4707ba24","html_url":"https://github.com/3Shain/multishot-generator","commit_stats":null,"previous_names":["3shain/multishot-generator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/3Shain/multishot-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Shain%2Fmultishot-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Shain%2Fmultishot-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Shain%2Fmultishot-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Shain%2Fmultishot-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3Shain","download_url":"https://codeload.github.com/3Shain/multishot-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Shain%2Fmultishot-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270183606,"owners_count":24541341,"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-08-13T02:00:09.904Z","response_time":66,"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":[],"created_at":"2024-10-05T08:10:40.281Z","updated_at":"2025-08-13T05:03:22.414Z","avatar_url":"https://github.com/3Shain.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multishot Generator\n\nThe `multishot-generator` package provides a unique implementation of multishot generators in TypeScript. This implementation allows generators to be \"forked\" at any yield point, creating new generators that can continue independently from that point. It is particularly useful in scenarios where you need to explore different paths of execution from a certain state in a generator function.\n\n## Features\n\n- **Efficient Forking**: Create new generator instances at any yield point with minimal overhead (No fork, no replay).\n- **History Tracking**: Maintains a history of yielded values for accurate state replication.\n- **Pure Generators**: Assumes generator functions are pure for consistent behavior across forks.\n\n## Installation\n\nTo install the package, run the following command in your project directory:\n\n```bash\nnpm install multishot-generator\n```\n\n## API Reference\n\n### `multishot\u003cT, TReturn, TNext\u003e(generatorFn: () =\u003e Generator\u003cT, TReturn, TNext\u003e): () =\u003e MultishotGenerator\u003cT, TReturn, TNext\u003e`\n\nCreates a multishot generator function.\n\n- **`generatorFn`**: A generator function that will be used to create new generator instances.\n- **Returns**: A function that, when called, initiates the multishot generator process. This function returns a `MultishotGenerator` union.\n\n### `MultishotGenerator\u003cT, TReturn, TNext\u003e`\n\nThe `MultishotGenerator` type is a union of a tuple representing the state of a multishot generator at a specific point in its execution. It can be either of the following:\n\n1. **A Tuple for Yielded Values**: When the generator yields a value, the `MultishotGenerator` is a tuple of the form `[IteratorYieldResult\u003cT\u003e, NextFunction]`. This tuple consists of:\n   - **`IteratorYieldResult\u003cT\u003e`**: An object with a `value` property containing the yielded value of type `T`, and a `done` property which is `false`.\n   - **`NextFunction`**: A function with the signature `(value: TNext) =\u003e MultishotGenerator\u003cT, TReturn, TNext\u003e`. This function is used to continue or fork the generator's execution with a new value of type `TNext`.\n\n2. **A Tuple for Returned Values**: When the generator completes its execution, the `MultishotGenerator` is a tuple of the form `[IteratorReturnResult\u003cTReturn\u003e]`. This tuple consists of:\n   - **`IteratorReturnResult\u003cTReturn\u003e`**: An object with a `value` property containing the final return value of type `TReturn`, and a `done` property which is `true`.\n\nThe `MultishotGenerator` type allows users to manage the execution of a generator, providing the capability to either continue the generator with a new value or to handle its completion.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue for any bugs, feature requests, or improvements.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3shain%2Fmultishot-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3shain%2Fmultishot-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3shain%2Fmultishot-generator/lists"}