{"id":18739016,"url":"https://github.com/gaubee/mix-async-generator","last_synced_at":"2025-10-15T08:35:08.772Z","repository":{"id":53030752,"uuid":"355926729","full_name":"Gaubee/mix-async-generator","owner":"Gaubee","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-09T02:52:12.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-20T03:37:34.934Z","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/Gaubee.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}},"created_at":"2021-04-08T13:52:38.000Z","updated_at":"2021-12-18T09:35:10.000Z","dependencies_parsed_at":"2022-09-02T04:12:30.140Z","dependency_job_id":null,"html_url":"https://github.com/Gaubee/mix-async-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Gaubee/mix-async-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Fmix-async-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Fmix-async-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Fmix-async-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Fmix-async-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gaubee","download_url":"https://codeload.github.com/Gaubee/mix-async-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gaubee%2Fmix-async-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279061737,"owners_count":26095463,"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-15T02:00:07.814Z","response_time":56,"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-11-07T15:32:26.262Z","updated_at":"2025-10-15T08:35:08.724Z","avatar_url":"https://github.com/Gaubee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MIX-AsyncGenerator\n\n## Install\n\n```\nnpm i mix-async-generator\n```\n\n## How to use\n\n### example 1\n\n```ts\nconst mixAG = new MixAsyncGenerator();\nmixAG.join(\n  (async function* someAg1() {\n    yield 1;\n    yield 3;\n  })()\n);\nmixAG.join(\n  (async function* someAg2() {\n    yield 2;\n    yield 4;\n  })()\n);\n\nfor await (const num of mixAG.toAsyncIterator()) {\n  console.log(num);\n}\n```\n\n\u003e output\n\n```\n1\n2\n3\n4\n```\n\n### example 2\n\n\u003e use `bench:boolean` to join an dispensable task.\n\n```ts\nconst mixAG = new MixAsyncGenerator();\nmixAG.join(\n  (async function* important() {\n    yield `important: 1`;\n    yield `important: 2`;\n    await sleep(100);\n    yield `important: 3`;\n  })()\n);\nmixAG.join(\n  (async function* dispensable() {\n    yield `dispensable: 1`;\n    yield `dispensable: 2`;\n    yield `dispensable: 3`;\n  })(),\n  {\n    bench: true,\n  }\n);\n\nfor await (const str of mixAG.toAsyncIterator()) {\n  console.log(str);\n}\n```\n\n\u003e output\n\n```\nimportant: 1\nimportant: 2\ndispensable: 1\ndispensable: 2\ndispensable: 3\nimportant: 3\n```\n\n### example 3\n\n\u003e use `jumpGun:number\u003e=1` to preload the specified amount.\n\n```ts\nconst mixAG = new MixAsyncGenerator();\n\nasync function* yieldNum(start = 0, end = start + 1) {\n  while (start \u003c= end) {\n    yield start++;\n  }\n}\nmixAG.join(yieldNum(1, 4));\nmixAG.join(yieldNum(10, 19), {\n  jumpGun: 3,\n});\n\nfor await (const str of mixAG.toAsyncIterator()) {\n  console.log(str);\n}\n```\n\n\u003e output\n\n```\n1 // preload 1 result. this is default\n10 // preload 3 result. config by 'jumpGun'\n2\n11\n12\n13\n3\n14\n15\n16\n4\n17\n18\n19\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaubee%2Fmix-async-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaubee%2Fmix-async-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaubee%2Fmix-async-generator/lists"}