https://github.com/jotsr/lazy_pipe
Simple lazy evaluation of value piping. Create the logic before and compute the value only when needed.
https://github.com/jotsr/lazy_pipe
deno lazy-evaluation typescript
Last synced: 3 months ago
JSON representation
Simple lazy evaluation of value piping. Create the logic before and compute the value only when needed.
- Host: GitHub
- URL: https://github.com/jotsr/lazy_pipe
- Owner: JOTSR
- License: mit
- Created: 2023-02-08T08:45:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-19T11:48:06.000Z (over 2 years ago)
- Last Synced: 2025-10-30T19:55:41.554Z (8 months ago)
- Topics: deno, lazy-evaluation, typescript
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LazyPipe - lazy evaluator pipeline
[](https://jsr.io/@jotsr/lazy-pipe)
[](https://jsr.io/@jotsr/lazy-pipe/doc)
[](https://opensource.org/licenses/MIT)
Simple lazy evaluation of value piping. Create the logic before and compute the
value only when needed.
# Examples
```ts
const lazyValue = new Lazy(veryBigArray)
.pipe((self) => self.map((x) => 2 * x))
.pipe((self) => self.toReversed())
.pipe((self) => self.toSorted())
.pipe((self) => self.reduce((acc, curr) => acc - curr, 0))
if (rareCondition) {
console.log(lazyValue.value)
}
```