{"id":19968375,"url":"https://github.com/olehdevua/lazyiter","last_synced_at":"2026-06-09T19:31:48.187Z","repository":{"id":84480829,"uuid":"60643423","full_name":"olehdevua/lazyiter","owner":"olehdevua","description":"Lazy iterators for JS","archived":false,"fork":false,"pushed_at":"2016-10-08T20:47:05.000Z","size":3,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-18T10:31:23.000Z","etag":null,"topics":["iterator","js","lazy"],"latest_commit_sha":null,"homepage":null,"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/olehdevua.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,"governance":null}},"created_at":"2016-06-07T20:16:05.000Z","updated_at":"2024-03-02T08:03:44.000Z","dependencies_parsed_at":"2023-03-12T23:06:31.644Z","dependency_job_id":null,"html_url":"https://github.com/olehdevua/lazyiter","commit_stats":null,"previous_names":["olegtsyba/lazyiter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/olehdevua/lazyiter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olehdevua%2Flazyiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olehdevua%2Flazyiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olehdevua%2Flazyiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olehdevua%2Flazyiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olehdevua","download_url":"https://codeload.github.com/olehdevua/lazyiter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olehdevua%2Flazyiter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34123171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"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":["iterator","js","lazy"],"created_at":"2024-11-13T02:45:38.163Z","updated_at":"2026-06-09T19:31:48.171Z","avatar_url":"https://github.com/olehdevua.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lazy iterator\n\nCreates iterator that iterate over collection lazily\n\n## Example:\n\n```js\nconst iter = require('lazyiter');\n\nfunction fib(n) {\n    return n \u003c 2 ? n : fib(n-2) + fib(n-1);\n}\n\nvar list = iter([11, 22, 133, 144, 155]);\n\nlist.map(fib).take(2).collect() // [ 89, 17711 ]\n\n// and no big CPU consumption, because of laziness\n```\n\nYou can pass iterators between functions and add new layers in any moment,\nand no computation happens until you apply `eager` method\n\n```js\nfunction foo(arr) {\n    // no computation here\n    return lazyiter(arr).map(e =\u003e e.toUpperCase())\n}\n\nvar a = foo([\"Oleg\", \"Jeka\", \"Dimon\", \"Demian\", \"Artem\", \"Escobar\"]);\n\n// add new layers\n\na.take(3).filter(e =\u003e e.length \u003c 6)\n\n// compute either with `collect`\na.collect() // [ 'OLEG', 'JEKA', 'DIMON' ]\n\n// or by hand (note: iterator can be traversed only once)\na.next();  // { value: 'OLEG', done: false }\na.next();  // { value: 'JEKA', done: false }\na.next();  // { value: 'DIMON', done: false }\na.next();  // { value: undefined, done: true }\n```\n\n## Methods\n\n### Lazy:\n- __map__(fn)      - return new iterator that apply `fn` to every entry\n- __filter__(fn)   - return new iterator that apply `fn` to every entry and\n  exlude the entry if `fn` return `false`\n- __takewhile__(fn) - return new iterator that apply `fn` to every entry until\n  `fn` return `false` and exclude enries for which `fn` return `false` and rest\n  of enries for which `fn` was not applied\n- __take(n)__ - return new iterator that has only first `n` entries\n\n### Eager:\n- __forEach__(fn) - go through enries and apply `fn` to each entry\n- __find__(fn) - go throuh entries and apply `fn` for each entry until `fn`\n  return `true`, return the entry for which `fn` return `true`\n- __reduce__([acc,] fn) - reduce enries with `fn`\n- __collect__() - convert iterator into array\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdevua%2Flazyiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folehdevua%2Flazyiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdevua%2Flazyiter/lists"}