https://github.com/mustaddon/iterq
Memory usage optimization in cascading iterable queries
https://github.com/mustaddon/iterq
Last synced: 8 months ago
JSON representation
Memory usage optimization in cascading iterable queries
- Host: GitHub
- URL: https://github.com/mustaddon/iterq
- Owner: mustaddon
- License: mit
- Created: 2022-08-24T17:26:53.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-27T17:59:40.000Z (almost 4 years ago)
- Last Synced: 2025-02-01T02:34:31.606Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iterq [](https://www.npmjs.com/package/iterq)
Memory usage optimization in cascading iterable queries
```ts
import { IterQuery } from "iterq";
let query = new IterQuery('someone iterable object for example')
// filtering doesn't generate any arrays
.filter(x => x != ' ')
// grouping will create one temp Map, but only after executing the query
.group(x => x)
// mapping doesn't generate any arrays
.map(g => ({ char: g[0], count: g[1].length }))
// take/skip works like a filter
.take(4);
// query execution. callbacks/predicates has not been executed before this line
for (let x of query)
console.log(x);
//// Console output:
// {char: 's', count: 1}
// {char: 'o', count: 4}
// {char: 'm', count: 2}
// {char: 'e', count: 7}
```