{"id":23282483,"url":"https://github.com/n8brooks/generator_helpers","last_synced_at":"2026-02-23T10:43:23.975Z","repository":{"id":45581907,"uuid":"412878444","full_name":"N8Brooks/generator_helpers","owner":"N8Brooks","description":"⚡ Synchronous generator monkey-patch for  proposal-iterator-helpers written in TypeScript for Deno.","archived":false,"fork":false,"pushed_at":"2024-10-15T19:10:57.000Z","size":60,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T23:42:40.375Z","etag":null,"topics":["deno","iterator","typescript"],"latest_commit_sha":null,"homepage":"https://deno.land/x/generator_helpers","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/N8Brooks.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,"zenodo":null}},"created_at":"2021-10-02T18:20:35.000Z","updated_at":"2024-10-15T19:11:01.000Z","dependencies_parsed_at":"2025-08-21T13:33:45.148Z","dependency_job_id":"a8da9c61-6ff5-4922-8316-3619058d7743","html_url":"https://github.com/N8Brooks/generator_helpers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/N8Brooks/generator_helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/N8Brooks%2Fgenerator_helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/N8Brooks%2Fgenerator_helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/N8Brooks%2Fgenerator_helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/N8Brooks%2Fgenerator_helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/N8Brooks","download_url":"https://codeload.github.com/N8Brooks/generator_helpers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/N8Brooks%2Fgenerator_helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280583894,"owners_count":26355258,"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-23T02:00:06.710Z","response_time":142,"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":["deno","iterator","typescript"],"created_at":"2024-12-20T00:17:38.936Z","updated_at":"2025-10-23T07:58:00.736Z","avatar_url":"https://github.com/N8Brooks.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# generator_helpers\n\n[![generator_helpers code coverage](https://img.shields.io/codecov/c/github/N8Brooks/generator_helpers?logo=deno)](https://app.codecov.io/gh/N8Brooks/generator_helpers)\n\nThis module monkey patches\n[proposal-iterator-helpers](https://github.com/tc39/proposal-iterator-helpers)\nonto JavaScript or TypeScript generators. After importing this module, methods\nthat can normally only be used on arrays can also be used on generators. Methods\nthat take a function as an argument are given the `value` and `index` of\nelements as parameters. A list of all monkey patched methods is provided below.\nCheck the proposal-iterator-helpers repository for more information and\nexamples.\n\n- [`.map(mapperFn)`](https://github.com/tc39/proposal-iterator-helpers#mapmapperfn)\n- [`.filter(filtererFn)`](https://github.com/tc39/proposal-iterator-helpers#filterfiltererfn)\n- [`.take(limit)`](https://github.com/tc39/proposal-iterator-helpers#takelimit)\n- [`.drop(limit)`](https://github.com/tc39/proposal-iterator-helpers#droplimit)\n- [`.asIndexedPairs()`](https://github.com/tc39/proposal-iterator-helpers#asindexedpairs)\n- [`.flatMap(mapperFn)`](https://github.com/tc39/proposal-iterator-helpers#flatmapmapperfn)\n- [`.reduce(reducer [, initialValue ])`](https://github.com/tc39/proposal-iterator-helpers#reducereducer--initialvalue-)\n- [`.toArray()`](https://github.com/tc39/proposal-iterator-helpers#toarray)\n- [`.forEach(fn)`](https://github.com/tc39/proposal-iterator-helpers#foreachfn)\n- [`.some(fn)`](https://github.com/tc39/proposal-iterator-helpers#somefn)\n- [`.every(fn)`](https://github.com/tc39/proposal-iterator-helpers#everyfn)\n- [`.find(fn)`](https://github.com/tc39/proposal-iterator-helpers#findfn)\n\nAdditionally `range` is provided as a helper generator as well as the\n`Iterator.from` method.\n\n- `range(stop)`\n- `range(start, stop [, step = 1 ])`\n- [`.from(object)`](https://github.com/tc39/proposal-iterator-helpers#fromobject)\n\n## Examples\n\n### `.map(mapperFn)` and `.toArray()`\n\nThe `.map(mapperFn)` method yields the results of `mapperFn` called with the\n`value` and `index` of every element passed as parameters.\n\nThe `.toArray()` method returns the generator cast to an `Array`.\n\n```ts\nimport \"https://deno.land/x/generator_helpers/monkey_patch.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nfunction* lowercase(): Generator\u003cstring\u003e {\n  yield \"a\";\n  yield \"b\";\n  yield \"c\";\n}\n\nconst uppercase = lowercase()\n  .map((char) =\u003e char.toUpperCase())\n  .toArray()\n  .join(\"\");\n\nassertEquals(uppercase, \"ABC\");\n```\n\n### `range(limit)` and `.reduce(reducer [, initialValue ])`\n\nThe `range(stop)` or `range(start, stop [, step = 1 ])` function is not included\nin iterator-helpers proposal, but is included as a utility. It yields from `0`\nup to, but not included, the `y0` parameter. If `y1` and `yd` are provided it\nyields from `y0` until `y1` with steps of `yd`. The `yd` parameter is `1` by\ndefault.\n\nThe `.reduce(reducer [, initialValue ])` method applies the `reducer` function\nto each value using the previous result for for the first parameter. The first\ntime it is called `initialValue` is used if provided or else the first item of\nthe generator. The third parameter that is provided to `mapperFn` is the current\n`index`.\n\n```ts\nimport { range } from \"https://deno.land/x/generator_helpers/monkey_patch.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst sum = range(10).reduce((prev, cur) =\u003e prev + cur, 0);\n\nassertEquals(sum, 45);\n```\n\n### `.flatMap(mapperFn)`\n\nThe `.flatMap(mapperFn)` method flattens the results from calls to `mapperFn`. Thereby\nflattening the generator one level.\n\n```ts\nimport { range } from \"https://deno.land/x/generator_helpers/monkey_patch.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst oneArray = range(5).flatMap((value) =\u003e Array(value).fill(value));\n\nassertEquals(oneArray, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn8brooks%2Fgenerator_helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn8brooks%2Fgenerator_helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn8brooks%2Fgenerator_helpers/lists"}