Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/r-unic/rbx-lazy-iterator
Combines multiple array operations into an iterator and only applies operations when the iterator is processed
https://github.com/r-unic/rbx-lazy-iterator
Last synced: about 2 months ago
JSON representation
Combines multiple array operations into an iterator and only applies operations when the iterator is processed
- Host: GitHub
- URL: https://github.com/r-unic/rbx-lazy-iterator
- Owner: R-unic
- Created: 2024-12-02T16:18:39.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2024-12-02T17:22:19.000Z (about 2 months ago)
- Last Synced: 2024-12-02T18:31:09.617Z (about 2 months ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LazyIterator
Combines multiple array operations into an iterator and only applies operations when the iterator is processed## Example
```ts
import LazyIterator from "@rbxts/lazy-iterator";const sum = LazyIterator.fromArray([1,2,3,4,5,6,7,8])
.map(n => n * 3) // triple all numbers
.filter(n => n % 2 === 0) // filter out odd numbers
.reduce((sum, n) => sum + n); // apply all operations then add up all numbersprint(sum); // 60
```