{"id":40730200,"url":"https://github.com/ugaya40/leseq","last_synced_at":"2026-01-21T14:31:11.447Z","repository":{"id":43042955,"uuid":"460357405","full_name":"ugaya40/leseq","owner":"ugaya40","description":"Lazy collection(lazy list) with high tree-shaking affinity and easy customization.","archived":false,"fork":false,"pushed_at":"2024-08-20T21:27:54.000Z","size":1496,"stargazers_count":27,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-17T18:37:05.114Z","etag":null,"topics":["async-iterable","collection","iterable","lazy-evaluation","lazy-sequences","lazylist","tree-shakable","typescript","zero-dependency"],"latest_commit_sha":null,"homepage":"","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/ugaya40.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":"2022-02-17T09:03:53.000Z","updated_at":"2025-06-23T17:14:15.000Z","dependencies_parsed_at":"2024-08-21T05:32:23.521Z","dependency_job_id":null,"html_url":"https://github.com/ugaya40/leseq","commit_stats":{"total_commits":102,"total_committers":3,"mean_commits":34.0,"dds":0.02941176470588236,"last_synced_commit":"90003995b3a2db18f25f3bdd21c3faa654563486"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/ugaya40/leseq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ugaya40%2Fleseq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ugaya40%2Fleseq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ugaya40%2Fleseq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ugaya40%2Fleseq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ugaya40","download_url":"https://codeload.github.com/ugaya40/leseq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ugaya40%2Fleseq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28634807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["async-iterable","collection","iterable","lazy-evaluation","lazy-sequences","lazylist","tree-shakable","typescript","zero-dependency"],"created_at":"2026-01-21T14:31:10.800Z","updated_at":"2026-01-21T14:31:11.441Z","avatar_url":"https://github.com/ugaya40.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/leseq.svg)](https://badge.fury.io/js/leseq)\n\nLazy list(lazy list) with high tree-shaking affinity and easy customization.\n\n# Features\n- 🎁 **Lazy Collection**: The collections are only enumerated to the minimum necessary. Infinite sequences are supported.\n- 🎄 **Tree-Shakeable**: Only the features you use will be bundled.\n- 👻 **Async Iterator Support**: *Iterable* can also be seamlessly treated as *Async Iterator*.\n- 📎 **Easy-Customization**: You can easily create the functions you need by yourself. [In this way.](https://ugaya40.github.io/leseq/create/)\n- 🗂 **Rxjs-like Syntax**: To achieve tree-shaking, we use an [rxjs](https://rxjs.dev/)-like syntax.\n- ✅ **Simple Equality Strategy**: It uses a simple [Equality Strategy](https://ugaya40.github.io/leseq/equality/).\n- 💯 **All Typed**: The whole thing is written in TypeScript, which also provides completion for type conversion between operators.\n- 💨 **No dependencies**\n\n```typescript\nimport {from, map, take} from 'leseq';\n\nconst result1 = from([1,2,3,4,5]).pipe(\n  map(i =\u003e i * i),\n  take(3)\n).toArray();\n\n//result1: [1,4,9]\n```\nThis is the result of [bundle visualizer](https://github.com/btd/rollup-plugin-visualizer) in the example above (1.21KB gzipped).\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1430166/158516201-cd001af0-1177-49ad-a59d-c3079f8a88f7.png\" width=\"350px\"\u003e\u003c/img\u003e\n\n# Resource\n- ### [Demo(StackBlitz)](https://stackblitz.com/edit/typescript-vygaa6?devtoolsheight=33\u0026file=index.ts)\n\n- ### [Docs](https://ugaya40.github.io/leseq/)\n\n# Advanced\n- #### [Create Original Functions](https://ugaya40.github.io/leseq/create/)\n\n- #### [Equality Strategy](https://ugaya40.github.io/leseq/equality/)\n\n- #### [Finalization, and Resource Management](https://ugaya40.github.io/leseq/finalize/)\n\n# Getting Started\n```\nnpm install leseq\n```\nIf you are using Async Iterable and *\"target \"* in **tsconfig.json** is smaller than **\"es2018\"**, you must add **\"ES2018.AsyncGenerator \"** and **\"ES2018.AsyncIterable \"** in **tsconfig.json/lib** or the type will not display properly.\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"es6\",\n    \"lib\": [\"DOM\", \"ES6\", \"ES2018.AsyncGenerator\", \"ES2018.AsyncIterable\"]\n  }\n}\n\n```\n## Iterable\n```typescript\nimport {from, map, take, find, range, reverse, filter} from 'leseq';\n\nconst result1 = from([1,2,3,4,5]).pipe(\n  map(i =\u003e i * i),\n  take(3)\n)\n\nfor (const one of result1) {\n  console.log(one)\n}\n\n//result: 1\n//result: 4\n//result: 9\n\nconst result2 = from([1,2,3,4,5]).pipe(\n  filter(i =\u003e i % 2 == 0)\n).value(\n  find(i =\u003e i \u003e 2)\n);\n\n//result2: 4\n\n//lazy\nconst result3 = range(1, 10000000).pipe(\n  take(3),\n  reverse(),\n  map((i) =\u003e i * i)\n).toArray();\n\n//result3: [9,4,1]\n```\n## Async Iterable\n```typescript\nimport {from, mapAsync, filterAsync, fromAsAsync, findAsync, asyncSeq} from 'leseq';\n\nconst sleep = (milliseconds: number) =\u003e new Promise(resolve =\u003e setTimeout(resolve,milliseconds));\n\n//from iterable to async iterable.\nconst result1 = await from([1,2,3,4,5]).to(asyncSeq()).pipe(\n  mapAsync(async i =\u003e {\n    await sleep(1000);\n    return i * i;\n  }),\n  filterAsync(async i =\u003e i % 2 == 0)\n).toArrayAsync();\n\n//5 seconds later... result1: [4,16]\n\nconst result2 = await fromAsAsync([1,2,3,4,5]).pipe(\n  mapAsync(async i =\u003e {\n    await sleep(1000);\n    return i * i;\n  }),\n  filterAsync(async i =\u003e i % 2 == 0)\n).valueAsync(findAsync());\n\n//2 seconds later... result2: 4\n\nconst result3 = await fromConcatAsAsync([1,2],[3,4]).pipe(\n  mapAsync(async i =\u003e {\n    await sleep(1000);\n    return i * i;\n  }),\n);\n\nfor await (const one of result3) {\n  console.log(one);\n}\n\n//1 seconds later... result: 1\n//2 seconds later... result: 4\n//3 seconds later... result: 9\n//4 seconds later... result: 16\n```\n# Usage\n\nIt is possible to generate sequences (Seq\u0026lt;T\u0026gt;/AsyncSeq\u0026lt;T\u0026gt; object) with **Generator**, convert them to sequences with different characteristics with **To**, perform operations such as value conversion and filtering with any number of **Operators**, and convert them to a single value with **Value**.\n\n```typescript\n// sync iterator\nSyncSource = \n  Generators(ex: from, fromConcat, ..etc) | \n  SyncSource.to(To(ex: share, async))\n  SyncSource.pipe(\n    ...SyncOperators(ex: map, filter, ...etc)\n  );\n\nvalue = SyncSource.value(SyncValues(ex: find,some, ...etc));\n\n// async iterator\nAsyncSource = \n  AsyncGenerators(ex: fromAsAsync, fromConcatAsAsync, ...etc) |\n  SyncSource.to(asyncSeq()) | // iterable to async iterable. |\n  AsyncSource.to(To(ex: shareAsync)) |\n  AsyncSource.pipe(\n    ...AsyncOperators(ex: mapAsync, filterAsync, ...etc)\n  );\n\nvalue = await AsyncSource.valueAsync(AsyncValues(ex: findAsync,someAsync, ...etc));\n```\n\nBecause it is a lazy list, it does not execute processing when **pipe()**/**to()** is called, but only when **value(valueAsync)**, **toArray(toArrayAsync)/toMutableArray(toMutableArrayAsync)**, or **forEach(forEachAsync)** is called.\n\n\u003e Changes from \"Iterable\" or Seq\u003cT\\\u003e to \"Async Iterable\" can be made at any time with **.to(asyncSeq())**.\nbut **Once the chain is changed to \"Async Iterable\" by **.to(asyncSeq())** or other means, only the asynchronous version of Operator/Value can be used in the same chain thereafter.** This is because, in principle, it is impossible to change from an \"Async Iterable\" to \"Iterable\".\n\nThe predefined **Generators/Operators/To/Values** are as follows. And all of them have asynchronous versions(*xxxAsAsync* or *xxxAsync*).\n\nIf the function you want to use does not exist, you can also define your own Operator/Value function [in this way](https://ugaya40.github.io/leseq/create/).\n\n## Predefined Generators\n| Generator | Description |\n| --- | --- |\n| [defer](https://ugaya40.github.io/leseq/api/generators/#defer) | Generates a sequence that delays the generation of sources until the actual enumeration is performed. (async version: [deferAsAsync](https://ugaya40.github.io/leseq/api/generators/#deferasasync) )  | |\n| [deferFromPromise](https://ugaya40.github.io/leseq/api/generators/#deferfrompromise) | **[Async Only]** Generates a sequence whose values are the result of sequential execution of a single Promise or multiple Promises; Promise execution is delayed until the sequence is enumerated.   | |\n| [deferValue](https://ugaya40.github.io/leseq/api/generators/#defervalue) | Generates a sequence that delays the generation of the source until the actual enumeration is performed. the source in deferValue consists of a single value. (async version: [deferValueAsAsync](https://ugaya40.github.io/leseq/api/generators/#defervalueasasync) )  | |\n| [from](https://ugaya40.github.io/leseq/api/generators/#from) | Generates a sequence from an iterable object. (async version: [fromAsAsync](https://ugaya40.github.io/leseq/api/generators/#fromasasync) ) | |\n| [fromConcat](https://ugaya40.github.io/leseq/api/generators/#fromconcat) | Generates a concatenated sequence of multiple iterable objects. (async version: [fromConcatAsAsync](https://ugaya40.github.io/leseq/api/generators/#fromconcatasasync) )  | |\n| [fromValue](https://ugaya40.github.io/leseq/api/generators/#fromvalue) | Generates a sequence from a single value. (async version: [fromValueAsAsync](https://ugaya40.github.io/leseq/api/generators/#fromvalueasasync) )  | |\n| [range](https://ugaya40.github.io/leseq/api/generators/#range) | Generates a sequential number sequence. (async version: [rangeAsAsync](https://ugaya40.github.io/leseq/api/generators/#rangeasasync) )  | |\n| [zip](https://ugaya40.github.io/leseq/api/generators/#zip) | Generates a sequence of arrays made by concatenating the elements of multiple sequences one at a time. (async version: [zipAsAsync](https://ugaya40.github.io/leseq/api/generators/#zipasasync) )  | |\n\n## Predefined To\n| To | Description |\n| --- | --- |\n| [async](https://ugaya40.github.io/leseq/api/to/#async) | Converts the current sequence to AsyncSeq\u003cT\\\u003e and returns it. | |\n| [share](https://ugaya40.github.io/leseq/api/to/#share) | Converts the current sequence to SharedSeq\u003cT\\\u003e and returns it; in a SharedSeq\u003cT\\\u003e, `iterator` is share until `close` method is called. (async version: [shareAsync](https://ugaya40.github.io/leseq/api/to/#shareasyncseq) ) | |\n\n## Predefined Operators\nIt is used within the pipe method of the Seq\u0026lt;T\u0026gt; object. Any number of operators can be connected.\n\n| Operator | Description |\n| --- | --- |\n| [catchError](https://ugaya40.github.io/leseq/api/operators/#catchError) | If the original iterable sequence raises an exception, the specified action is performed, terminating the enumeration or enumerating an alternate sequence. (async version: [catchErrorAsync](https://ugaya40.github.io/leseq/api/operators/#catcherrorasync) ) | |\n| [chunk](https://ugaya40.github.io/leseq/api/operators/#chunk) | Returns a sequence divided into array of the specified size. (async version: [chunkAsync](https://ugaya40.github.io/leseq/api/operators/#chunkasync) )  | |\n| [chunkByAccumulation](https://ugaya40.github.io/leseq/api/operators/#chunkbyaccumulation) | Returns a sequence divided into arrays based on an accumulation function and a threshold condition. (async version: [chunkByAccumulationAsync](https://ugaya40.github.io/leseq/api/operators/#chunkbyaccumulationasync) )  | |\n| [concat](https://ugaya40.github.io/leseq/api/operators/#concat) | Returns a sequence in which the current sequence and the specified sequence are concatenated. (async version: [concatAsync](https://ugaya40.github.io/leseq/api/operators/#concatasync) )  | |\n| [concatValue](https://ugaya40.github.io/leseq/api/operators/#concatvalue) | Returns the sequence to which the specified value is added. (async version: [concatValueAsync](https://ugaya40.github.io/leseq/api/operators/#concatvalueasync) )  | |\n| [difference](https://ugaya40.github.io/leseq/api/operators/#difference) | Returns the sequence that is the difference set between the current sequence and the specified sequence. (async version: [differenceAsync](https://ugaya40.github.io/leseq/api/operators/#differenceasync) )  | |\n| [filter](https://ugaya40.github.io/leseq/api/operators/#filter) | Returns a sequence that has been filtered by the specified condition. (async version: [filterAsync](https://ugaya40.github.io/leseq/api/operators/#filterasync) )  | |\n| [finalize](https://ugaya40.github.io/leseq/api/operators/#finalize) | Invokes a specified action after the source iterable sequence terminates normally or exceptionally. (async version: [finalizeAsync](https://ugaya40.github.io/leseq/api/operators/#finalizeasync) )  | |\n| [flatten](https://ugaya40.github.io/leseq/api/operators/#flatten) | Returns a flattened sequence. (async version: [flattenAsync](https://ugaya40.github.io/leseq/api/operators/#flattenasync) )  | |\n| [groupBy](https://ugaya40.github.io/leseq/api/operators/#groupby) | Returns a sequence grouped by a specified key. (async version: [groupByAsync](https://ugaya40.github.io/leseq/api/operators/#groupbyasync) )  | |\n| [intersect](https://ugaya40.github.io/leseq/api/operators/#intersect) | Returns a sequence that is the product set of the current sequence and the specified sequence. (async version: [intersectAsync](https://ugaya40.github.io/leseq/api/operators/#intersectasync) )  | |\n| [map](https://ugaya40.github.io/leseq/api/operators/#map) | Returns the sequence in which each element has been transformed by the specified transformation function. (async version: [mapAsync](https://ugaya40.github.io/leseq/api/operators/#mapasync) )  | |\n| [orderBy](https://ugaya40.github.io/leseq/api/operators/#orderby) | Returns a sequence sorted by a specified key. (async version: [orderByAsync](https://ugaya40.github.io/leseq/api/operators/#orderbyasync) )  | |\n| [repeat](https://ugaya40.github.io/leseq/api/operators/#repeat) | Returns a sequence that repeats the source sequence a specified number of times. (async version: [repeatAsync](https://ugaya40.github.io/leseq/api/operators/#repeatasync) )  | |\n| [reverse](https://ugaya40.github.io/leseq/api/operators/#reverse) | Returns a sequence in reverse order of the current sequence. (async version: [reverseAsync](https://ugaya40.github.io/leseq/api/operators/#reverseasync) )  | |\n| [scan](https://ugaya40.github.io/leseq/api/operators/#scan) | Returns the resulting sequence after applying the aggregate function to the elements of the current sequence. (async version: [scanAsync](https://ugaya40.github.io/leseq/api/operators/#scanasync) )  | |\n| [skip](https://ugaya40.github.io/leseq/api/operators/#skip) | Returns the sequence with the specified number of skips. (async version: [skipAsync](https://ugaya40.github.io/leseq/api/operators/#skipasync) )  | |\n| [skipWhile](https://ugaya40.github.io/leseq/api/operators/#skipwhile) | Returns the sequence of elements skipped while matching the condition. (async version: [skipWhileAsync](https://ugaya40.github.io/leseq/api/operators/#skipwhileasync) )  | |\n| [take](https://ugaya40.github.io/leseq/api/operators/#take) | Returns a sequence that enumerates the specified number of items. (async version: [takeAsync](https://ugaya40.github.io/leseq/api/operators/#takeasync) )  | |\n| [takeWhile](https://ugaya40.github.io/leseq/api/operators/#takewhile) | Returns a sequence to be enumerated only while the condition is matched. (async version: [takeWhileAsync](https://ugaya40.github.io/leseq/api/operators/#takewhileasync) )  | |\n| [tap](https://ugaya40.github.io/leseq/api/operators/#tap) | Run side effects. (async version: [tapAsync](https://ugaya40.github.io/leseq/api/operators/#tapasync) )  | |\n| [union](https://ugaya40.github.io/leseq/api/operators/#union) | Returns a sequence that is the union set of the current sequence and the specified sequence. (async version: [unionAsync](https://ugaya40.github.io/leseq/api/operators/#unionasync) )  | |\n| [uniq](https://ugaya40.github.io/leseq/api/operators/#uniq) | Returns a deduplicated sequence. (async version: [uniqAsync](https://ugaya40.github.io/leseq/api/operators/#uniqasync) )  | |\n| [zipWith](https://ugaya40.github.io/leseq/api/operators/#zipwith) | Returns a sequence of arrays consisting of the elements of the source array and the elements of the multiple sequences given as arguments, concatenated one by one. (async version: [zipWithAsync](https://ugaya40.github.io/leseq/api/operators/#zipwithasync) )  | |\n\n\n\n## Predefined Values\nGenerates a value from a sequence. Used in the value method of the Seq\u0026lt;T\u0026gt; object.\n\n| Value | Description |\n| --- | --- |\n| [every](https://ugaya40.github.io/leseq/api/values/#every) | Returns whether or not all elements of a sequence meet the specified conditions. (async version: [everyAsync](https://ugaya40.github.io/leseq/api/values/#everyasync) )  | |\n| [find](https://ugaya40.github.io/leseq/api/values/#find) | Returns the first element that satisfies the condition. If no element satisfying the condition is found, an error is thrown. (async version: [findAsync](https://ugaya40.github.io/leseq/api/values/#findasync) )  | |\n| [findOrDefault](https://ugaya40.github.io/leseq/api/values/#findordefault) | Returns the first element that satisfies the condition. If no element is found that satisfies the condition, it returns the specified default value. (async version: [findOrDefaultAsync](https://ugaya40.github.io/leseq/api/values/#findordefaultasync) )  | |\n| [reduce](https://ugaya40.github.io/leseq/api/values/#reduce) | Returns the result of applying the aggregate function to the elements of the current sequence. (async version: [reduceAsync](https://ugaya40.github.io/leseq/api/values/#reduceasync) )  | |\n| [some](https://ugaya40.github.io/leseq/api/values/#some) | Returns whether or not any element of the sequence satisfies the specified condition. (async version: [someAsync](https://ugaya40.github.io/leseq/api/values/#someasync) )  | |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fugaya40%2Fleseq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fugaya40%2Fleseq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fugaya40%2Fleseq/lists"}