{"id":32963084,"url":"https://github.com/xgbuils/iterum","last_synced_at":"2026-01-25T01:04:39.116Z","repository":{"id":57227141,"uuid":"51874546","full_name":"xgbuils/iterum","owner":"xgbuils","description":"Handling iterables like lazy arrays.","archived":false,"fork":false,"pushed_at":"2017-08-02T21:21:33.000Z","size":570,"stargazers_count":29,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-17T02:03:50.685Z","etag":null,"topics":["functional","inmutable","iterable","iterator","lazy-evaluation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xgbuils.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-16T22:18:21.000Z","updated_at":"2023-02-26T02:18:32.000Z","dependencies_parsed_at":"2022-09-06T13:22:16.233Z","dependency_job_id":null,"html_url":"https://github.com/xgbuils/iterum","commit_stats":null,"previous_names":["xgbuils/es5-generator-utils"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/xgbuils/iterum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgbuils%2Fiterum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgbuils%2Fiterum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgbuils%2Fiterum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgbuils%2Fiterum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xgbuils","download_url":"https://codeload.github.com/xgbuils/iterum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgbuils%2Fiterum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28740423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["functional","inmutable","iterable","iterator","lazy-evaluation"],"created_at":"2025-11-13T01:00:34.904Z","updated_at":"2026-01-25T01:04:39.112Z","avatar_url":"https://github.com/xgbuils.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Control flow Generators","Control flow"],"readme":"# Iterum\n\n[![travis ci][1]][2]\n[![npm version][3]][4]\n[![Coverage Status][5]][6]\n[![Dependency Status][7]][8]\n\n`iterum` library provides a class for handling iterable transformations inspired in [Array methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) and [lodash/fp](https://github.com/lodash/lodash/wiki/FP-Guide) functions. This library also supplies combinatorial functions like [permutations](doc/API.md#permutations), [combinations](doc/API.md#combinations), [variations](doc/API.md#variations), [product](doc/API.md#product), [power](doc/API.md#power) and [powerSet](doc/API.md#powerset) that has a high computational cost but this library is able to support taking advantage of lazy evaluation.\n\n## Install\n\n``` bash\n$ npm install iterum --save\n```\n\n## Usage\n``` javascript\nconst Iterum = require('iterum')\nconst {range} = Iterum\n\nconst iterable = range(1, Infinity) // (1 2 3 4 5 6 7 8...)\n    .map(value =\u003e 2 * value) // (2 4 6 8 10 12 14 16...)\n    .filter(value =\u003e value % 3 === 0 || value % 3 === 1) // (4 6 10 12 16...)\n    .take(5) // (4 6 10 12 16)\n    .concat([1, 2, 3]) // (4 6 10 12 16 1 2 3)\n\n// converting to array:\n[...iterable] // [4, 6, 10, 12, 16, 1, 2, 3]\n\n// traversing values:\nfor (const val of iterable) {\n    // ...\n}\n\n// creating an iterator that traverses the values\nlet iterator = iterable[Symbol.iterator]()\niterator.next() // {value: 4, done: false}\niterator.next() // {value: 6, done: false}\niterator.next() // {value: 10, done: false}\niterator.next() // {value: 12, done: false}\niterator.next() // {value: 16, done: false}\niterator.next() // {value: 1, done: false}\niterator.next() // {value: 2, done: false}\niterator.next() // {value: 3, done: false}\niterator.next() // {value: undefined, done: true}\n```\n\n## Why Iterum?\n[Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) interface has been introduced by ES2015. An object that implements this interface has a `Symbol.iterator` property with a generator value which arity is 0. For example we can create an `obj` variable that implements `Iterable` interface:\n\n``` javascript\nlet obj = {\n    [Symbol.iterator]: function* () {\n        for (let i = 0; i \u003c= 10; ++i) {\n            yield i\n        }\n    }\n}\n```\n\nAny object that implements the Iterable interface can use [for..of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) statement and the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator). For example:\n\n``` javascript\n[...obj] // returns [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nfor (let x of obj) {\n  // x traverses all values between 0 and 10\n}\n```\n\nThen, `obj` can be processed as an ordered list of values. However, unlike [built-in iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#Built-in_iterables) (Array, Set, Map, String, etc), `obj` is a **lazy iterable**. It means that, thanks to generators, `obj` does not store the computed values in memory and its values are computed just when are required. These are the essential features for implementing lazy evaluation.\n\nIt is even possible to create a new iterable without computing or storing `obj` values in memory. This is an example of creating a new iterable that iterates over the double of values generated by `obj`:\n\n``` javascript\nlet doubleObj = {\n    [Symbol.iterator]: function* () {\n        for (const value of obj) {\n            yield 2 * value\n        }\n    }\n}\n\n[...doubleObj] // returns [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n```\n\n`iterum` is a library that takes advantage of these techniques to provide a collection of functions and methods that apply iterable transformations without traversing values. Then, using `iterum`, the previous example could be expressed thus:\n\n``` javascript\nconst Iterum = require('iterum')\n\nconst obj = Iterum.range(0, 10) // (0 1 2 3 4 5 6 7 8 9 10)\n\nconst doubleObj = obj.map(e =\u003e 2 * e) // (0 2 4 6 8 10 12 14 16 18 20)\n```\n\n## [Features](doc/features.md)\n- [Functional \u0026 method chaining approach\n](doc/features.md)\n- [Maximizing support for infinite iterables](doc/features.md)\n- [No consumible iterables](doc/features.md)\n- [Combinatorial hight cost functions](doc/features.md)\n- [Thinking about modularity](doc/features.md)\n- [Thinking about performance](doc/features.md)\n\n## [API Documentation](doc/API.md)\n\n## Support\n- Node.js \u003e=6\n- ES2015 transpilers\n\n## Customized builds\n`Iterum` allows to build just what you need. Read [customized build section](doc/customized_builds.md) for more information.\n\n## License\nMIT\n\n  [1]: https://travis-ci.org/xgbuils/iterum.svg?branch=master\n  [2]: https://travis-ci.org/xgbuils/iterum\n  [3]: https://badge.fury.io/js/iterum.svg\n  [4]: https://badge.fury.io/js/iterum\n  [5]: https://coveralls.io/repos/github/xgbuils/iterum/badge.svg?branch=master\n  [6]: https://coveralls.io/github/xgbuils/iterum?branch=master\n  [7]: https://david-dm.org/xgbuils/iterum.svg\n  [8]: https://david-dm.org/xgbuils/iterum\n  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgbuils%2Fiterum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxgbuils%2Fiterum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgbuils%2Fiterum/lists"}