{"id":15286991,"url":"https://github.com/shun-shobon/iter-funcs","last_synced_at":"2025-10-20T17:46:33.950Z","repository":{"id":58397133,"uuid":"531322814","full_name":"shun-shobon/iter-funcs","owner":"shun-shobon","description":"Utility functions for iterators. Inspired by Rust's `std::iter::Iterator` trait.","archived":true,"fork":false,"pushed_at":"2024-02-01T10:56:05.000Z","size":97,"stargazers_count":8,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T13:17:32.641Z","etag":null,"topics":["deno","functional","functional-programming","iterator","javascript","typescript","utilities"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@shun-shobon/iter-funcs","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/shun-shobon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-09-01T01:42:52.000Z","updated_at":"2024-02-01T10:56:06.000Z","dependencies_parsed_at":"2023-12-21T19:11:32.045Z","dependency_job_id":"b08e3267-19f9-400a-ad66-adc326b80256","html_url":"https://github.com/shun-shobon/iter-funcs","commit_stats":{"total_commits":111,"total_committers":3,"mean_commits":37.0,"dds":0.4414414414414415,"last_synced_commit":"c957e825a695b27dc89d1732052baaac46ca32fc"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shun-shobon%2Fiter-funcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shun-shobon%2Fiter-funcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shun-shobon%2Fiter-funcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shun-shobon%2Fiter-funcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shun-shobon","download_url":"https://codeload.github.com/shun-shobon/iter-funcs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235575693,"owners_count":19012156,"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":["deno","functional","functional-programming","iterator","javascript","typescript","utilities"],"created_at":"2024-09-30T15:20:13.009Z","updated_at":"2025-10-07T01:31:04.285Z","avatar_url":"https://github.com/shun-shobon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iter-funcs\n\n[![npm](https://img.shields.io/npm/v/@shun-shobon/iter-funcs?logo=npm)](https://www.npmjs.com/package/@shun-shobon/iter-funcs)\n[![deno](https://img.shields.io/github/v/release/shun-shobon/iter-funcs?label=deno\u0026logo=deno)](https://deno.land/x/iter_funcs)\n[![test](https://github.com/shun-shobon/iter-funcs/actions/workflows/test.yml/badge.svg)](https://github.com/shun-shobon/iter-funcs/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/shun-shobon/iter-funcs/branch/master/graph/badge.svg?token=gwyScwGdCG)](https://codecov.io/gh/shun-shobon/iter-funcs)\n\n## About\n\nUtility functions for iterators. Inspired by Rust's\n[`std::iter::Iterator`](https://doc.rust-lang.org/std/iter/trait.Iterator.html)\ntrait. This library uses JavaScript native iterators, so it's compatible with\nany library that uses them.\n\n## Support platforms\n\n- Node.js\n- Deno\n- Browser\n\n## Installation\n\n\u003c!-- x-release-please-start-version --\u003e\n\n### Node.js\n\nInstall package from npm.\n\n```sh\nnpm install @shun-shobon/iter-funcs@1.7.0\n```\n\nYou can import from the package as `@shun-shobon/iter-funcs`.\n\n```ts\nimport { filter, map } from \"@shun-shobon/iter-funcs\";\n```\n\n### Deno\n\nYou can directly import from `deno.land/x`.\n\n```ts\nimport { filter, map } from \"https://deno.land/x/iter_funcs@1.7.0/mod.ts\";\n```\n\n### Browser\n\nYou can directly import from `unpkg.com`.\n\n```js\nimport {\n  filter,\n  map,\n} from \"https://unpkg.com/@shun-shobon/iter-funcs@1.7.0/esm/mod.js\";\n```\n\n\u003c!-- x-release-please-end --\u003e\n\n## Example\n\n\u003c!-- x-release-please-start-version --\u003e\n\nThis is a basic example.\n\n```ts\nimport {\n  filter,\n  forEach,\n  fromIterable,\n  map,\n  pipe,\n  take,\n} from \"https://deno.land/x/iter_funcs@1.7.0/mod.ts\";\n\nconst array = [1, 2, 3, 4, 5, 6];\n\npipe(\n  array,\n  fromIterable, // make iterator from iterable\n  filter((x) =\u003e x % 2 === 0), // filter even numbers\n  map((x) =\u003e x * 2), // multiply by 2\n  take(2), // take first 2 elements\n  forEach(console.log), // =\u003e 4, 8\n);\n```\n\nYou can also `AsyncIterator`.\n\n```ts\nimport { expandGlob } from \"https://deno.land/std/fs/mod.ts\";\nimport {\n  asyncFilter,\n  asyncForEach,\n  asyncMap,\n  asyncTake,\n  asyncToArray,\n  pipe,\n} from \"https://deno.land/x/iter_funcs@1.7.0/mod.ts\";\n\nconst files: Array\u003cstring\u003e = await pipe(\n  expandGlob(\"src/*.ts\"), // Find all .ts files in src directory\n  asyncMap((entry) =\u003e entry.path), // Get path from entry\n  asyncFilter((path) =\u003e !path.endsWith(\"_test.ts\")), // Exclude test files\n  asyncTake(2), // Take first 2 elements\n  asyncMap((path) =\u003e Deno.readTextFile(path)), // Read file content\n  asyncToArray, // Convert to array\n);\n```\n\n\u003c!-- x-release-please-end --\u003e\n\n## Difference from `Array.prototype` methods\n\nThis library's functions are **lazy**. They don't evaluate the whole iterator at\nonce. They evaluate only the needed elements. This is useful when you have a\nlarge iterator and you only need a few elements from it.\n\n## Why not use method chaining?\n\nMethod chaining is a common pattern in JavaScript. However, it tends to increase\nbundle size. It also makes it difficult to use with other libraries that use\niterators.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshun-shobon%2Fiter-funcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshun-shobon%2Fiter-funcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshun-shobon%2Fiter-funcs/lists"}