{"id":17609894,"url":"https://github.com/vitaly-t/iter-ops","last_synced_at":"2025-04-05T09:10:50.353Z","repository":{"id":45105163,"uuid":"424864804","full_name":"vitaly-t/iter-ops","owner":"vitaly-t","description":"Basic operations on iterables","archived":false,"fork":false,"pushed_at":"2024-08-09T17:51:58.000Z","size":3509,"stargazers_count":142,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T08:06:26.368Z","etag":null,"topics":["async","functional","iterable-extensions","iterables","typescript"],"latest_commit_sha":null,"homepage":"https://vitaly-t.github.io/iter-ops","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/vitaly-t.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":"2021-11-05T07:39:42.000Z","updated_at":"2025-03-26T09:02:17.000Z","dependencies_parsed_at":"2024-01-07T01:19:47.567Z","dependency_job_id":"61afef23-f6c1-4de3-ae5d-1d5f4c49aace","html_url":"https://github.com/vitaly-t/iter-ops","commit_stats":{"total_commits":918,"total_committers":4,"mean_commits":229.5,"dds":"0.13616557734204793","last_synced_commit":"4ccb7be7c33c09cf9ccb4206d1bc7f0d12c925ce"},"previous_names":[],"tags_count":174,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fiter-ops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fiter-ops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fiter-ops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitaly-t%2Fiter-ops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitaly-t","download_url":"https://codeload.github.com/vitaly-t/iter-ops/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312085,"owners_count":20918344,"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":["async","functional","iterable-extensions","iterables","typescript"],"created_at":"2024-10-22T17:10:46.217Z","updated_at":"2025-04-05T09:10:50.324Z","avatar_url":"https://github.com/vitaly-t.png","language":"TypeScript","funding_links":[],"categories":["Built with TypeScript"],"sub_categories":["Libraries"],"readme":"## iter-ops\n\n-   [About](#about)\n-   [Installation](#installation)\n-   [Usage](#usage)\n-   [API]\n\n[![Build Status](https://github.com/vitaly-t/iter-ops/workflows/ci/badge.svg?branch=main)](https://github.com/vitaly-t/iter-ops/actions?query=workflow%3Aci+branch%3Amain)\n\n## About\n\nBasic operations on [synchronous] + [asynchronous] iterables, strictly for JavaScript native types.\n\n![image](https://user-images.githubusercontent.com/5108906/147329472-38caa349-1baa-4ab0-945e-5cf618ce0dd9.png)\n\nWe do not use any synthetic types / wrappers here, like `Observable` in RXJS, etc. It is strictly an iterable on the\ninput, and an iterable on the output, for maximum performance, simplicity and compatibility (see [Rationale]).\n\nRelated repo: [iter-ops-extras] - addition to the [main API](https://vitaly-t.github.io/iter-ops/).\n\n## Installation\n\n```\n$ npm i iter-ops\n```\n\n## Usage\n\n-   Synchronous pipeline:\n\n```ts\nimport {pipe, filter, map} from 'iter-ops';\n\nconst input = [1, 2, 3, 4, 5];\n\nconst i = pipe(\n    input,\n    filter((a) =\u003e a % 2 === 0), // find even numbers\n    map((value) =\u003e ({value})) // remap into objects\n);\n\nconsole.log(...i); //=\u003e {value: 2}, {value: 4}\n```\n\n-   Asynchronous pipeline:\n\n```ts\nimport {pipe, toAsync, distinct, delay} from 'iter-ops';\n\nconst input = [1, 2, 2, 3, 3, 4];\n\nconst i = pipe(\n    toAsync(input), // make asynchronous\n    distinct(), // emit unique numbers\n    delay(1000) // delay each value by 1s\n);\n// or you can replace `pipe` + `toAsync` with just `pipeAsync`\n\n(async function () {\n    for await (const a of i) {\n        console.log(a); //=\u003e 1, 2, 3, 4 (with 1s delay)\n    }\n})();\n```\n\n_See also..._\n\n-   [Short API] list below, plus [Full API]\n-   [Benchmarks], for performance comparison\n-   [WiKi Pages], for additional resources\n\n## API\n\nFunction [pipe] takes any iterable, applies all specified operators to it, and returns an extended iterable.\nFor strict type of iterables, there are also [pipeSync] and [pipeAsync].\n\n#### \u003ci\u003eStandard Operators:\u003c/i\u003e\n\nAll standard operators implement the same logic as [Array] does:\n\n-   [concat](http://vitaly-t.github.io/iter-ops/functions/concat) - merges current iterable with multiple values,\n    iterators or iterables.\n-   [every](http://vitaly-t.github.io/iter-ops/functions/every) - checks if all elements pass the predicate test.\n-   [filter](http://vitaly-t.github.io/iter-ops/functions/filter) - standard filter processor, filtering by predicate.\n-   [flat](http://vitaly-t.github.io/iter-ops/functions/flat) - flattens/expands sub-iterable elements.\n-   [flatMap](http://vitaly-t.github.io/iter-ops/functions/flatMap) - remaps + flattens sub-iterable elements.\n-   [map](http://vitaly-t.github.io/iter-ops/functions/map) - standard mapping processor, remapping by predicate.\n-   [reduce](http://vitaly-t.github.io/iter-ops/functions/reduce) - standard reduce processor.\n-   [some](http://vitaly-t.github.io/iter-ops/functions/some) - checks if any element passes the predicate test.\n\n#### \u003ci\u003eExtended Operators:\u003c/i\u003e\n\n-   [aggregate](http://vitaly-t.github.io/iter-ops/functions/aggregate) - executes an aggregate on accumulated values -\n    see [Aggregates].\n-   [catchError](http://vitaly-t.github.io/iter-ops/functions/catchError) - catches iteration errors -\n    see [Error Handling].\n-   [count](http://vitaly-t.github.io/iter-ops/functions/count) - counts values, and produces a one-value iterable.\n-   [defaultEmpty](http://vitaly-t.github.io/iter-ops/functions/defaultEmpty) - adds default to an empty iterable.\n-   [distinct](http://vitaly-t.github.io/iter-ops/functions/distinct) - emits unique values, with optional key selector.\n-   [drain](http://vitaly-t.github.io/iter-ops/functions/drain) - drains the iterable, and then ends it.\n-   [empty](http://vitaly-t.github.io/iter-ops/functions/empty) - produces an empty iterable.\n-   [first](http://vitaly-t.github.io/iter-ops/functions/first) - produces a one-value iterable, with the first emitted\n    value.\n-   [indexBy](http://vitaly-t.github.io/iter-ops/functions/indexBy) - emits indexed values that pass the predicate test.\n-   [isEmpty](http://vitaly-t.github.io/iter-ops/functions/isEmpty) - produces a one-value iterable, indicating if the\n    source is empty.\n-   [last](http://vitaly-t.github.io/iter-ops/functions/last) - produces a one-value iterable, with the last emitted\n    value.\n-   [onEnd](http://vitaly-t.github.io/iter-ops/functions/onEnd) - notifies of the end of a successful iteration.\n-   [page](http://vitaly-t.github.io/iter-ops/functions/page) - splits values into pages of fixed size (last page can be\n    smaller).\n-   [repeat](http://vitaly-t.github.io/iter-ops/functions/repeat) - repeats iterable values.\n-   [skip](http://vitaly-t.github.io/iter-ops/functions/skip) - starts emitting values after certain count.\n-   [skipUntil](http://vitaly-t.github.io/iter-ops/functions/skipUntil) - skips until the predicate returns a truthy\n    value.\n-   [skipWhile](http://vitaly-t.github.io/iter-ops/functions/skipWhile) - skips while the predicate returns a truthy\n    value.\n-   [split](http://vitaly-t.github.io/iter-ops/functions/split) - splits values into separate lists - see [Split].\n-   [spread](http://vitaly-t.github.io/iter-ops/functions/spread) - spreads iterable values.\n-   [take](http://vitaly-t.github.io/iter-ops/functions/take) - emits up to certain number of values.\n-   [takeLast](http://vitaly-t.github.io/iter-ops/functions/takeLast) - emits up to certain number of the last values.\n-   [takeUntil](http://vitaly-t.github.io/iter-ops/functions/takeUntil) - emits until the predicate returns a truthy\n    value.\n-   [takeWhile](http://vitaly-t.github.io/iter-ops/functions/takeWhile) - emits while the predicate returns a truthy\n    value.\n-   [tap](http://vitaly-t.github.io/iter-ops/functions/tap) - taps into each value, without changing the output.\n-   [timeout](http://vitaly-t.github.io/iter-ops/functions/timeout) - ends iteration after N milliseconds.\n-   [timing](http://vitaly-t.github.io/iter-ops/functions/timing) - measures timings for each value.\n-   [toArray](http://vitaly-t.github.io/iter-ops/functions/toArray) - accumulates values into an array.\n-   [zip](http://vitaly-t.github.io/iter-ops/functions/zip) - zips values together, into an array.\n\n#### \u003ci\u003eCustom Operators:\u003c/i\u003e\n\nSee [iter-ops-extras] - a collection of custom operators (ones based on existing operators).\n\n#### \u003ci\u003eResources:\u003c/i\u003e\n\n-   [Short API] list below, plus [Full API]\n-   [Benchmarks], for performance comparison\n-   [WiKi Pages], for additional resources\n\n[api]: #api\n[short api]: #api\n[full api]: https://vitaly-t.github.io/iter-ops\n[error handling]: https://github.com/vitaly-t/iter-ops/wiki/Error-Handling\n[iterable]: https://javascript.info/iterable\n[iterables]: https://javascript.info/iterable\n[array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\n[wiki]: https://github.com/vitaly-t/iter-ops/wiki\n[pipe]: http://vitaly-t.github.io/iter-ops/functions/pipe\n[recipes]: https://github.com/vitaly-t/iter-ops/wiki/Recipes\n[state]: https://github.com/vitaly-t/iter-ops/wiki/Iteration-State\n[aggregates]: https://github.com/vitaly-t/iter-ops/wiki/Aggregates\n[split]: https://github.com/vitaly-t/iter-ops/wiki/Split\n[benchmarks]: ./benchmarks\n[asynchronous iterables]: https://github.com/vitaly-t/iter-ops/wiki/Asynchronous-Iterables\n[synchronous]: https://javascript.info/iterable\n[asynchronous]: https://javascript.info/async-iterators-generators#async-iterables\n[rationale]: https://github.com/vitaly-t/iter-ops/wiki/Rationale\n[pipesync]: https://vitaly-t.github.io/iter-ops/functions/pipeSync\n[pipeasync]: https://vitaly-t.github.io/iter-ops/functions/pipeAsync\n[wiki pages]: https://github.com/vitaly-t/iter-ops/wiki\n[iter-ops-extras]: https://github.com/vitaly-t/iter-ops-extras\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitaly-t%2Fiter-ops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitaly-t%2Fiter-ops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitaly-t%2Fiter-ops/lists"}