# @bdsqqq/lazytm

> Why compute something now, when you can compute it later?

Latest version **0.0.2** (published 2023-04-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bdsqqq/lazytm
pnpm add @bdsqqq/lazytm
yarn add @bdsqqq/lazytm
bun add @bdsqqq/lazytm
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-04-05 |
| First published | 2023-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Igor Bedesqui |
| Maintainers | bdsqqq |

## Links

- npm: https://www.npmjs.com/package/@bdsqqq/lazytm
- npm.io page: https://npm.io/package/@bdsqqq/lazytm

## Recent versions

- 0.0.2 (latest) — 2023-04-05
- 0.0.1 — 2023-04-04
- 0.0.0 — 2023-04-04

## README

# lazy™

Why compute something now, when you can compute it later?

lazy™ avoids unecessary compute using lazy iterators. Inspired by Rust's iterators and motivated by me trying to get the headers of a .csv file with a million entries.

## Usage

```
npm install @bdsqqq/lazytm
```

```ts
import { makeLazySplitIterator } from "@bdsqqq/lazytm";
import { this_could_be_a_gb_file } from "./bigassfile.csv";

const iterator = makeLazySplitIterator(this_could_be_a_gb_file, "\n");
const { value, done } = iterator.next().value;
```

## Why does this exist?

```ts
const absolutelly_huge_string_from_a_user_uploaded_file;
const headers =
  absolutelly_huge_string_from_a_user_uploaded_file.split("\n")[0];
```

blocked the main thread for a while and I only needed the first element to display some stuff in the screen.

## Why is the lib a single function?

Taking inspiration from the lazy iterator itself, I'll only make these functions as I need them. But the general idea can be applied to almost all String and Array methods in JavaScript so feel free to contribute.

---
_Source: https://npm.io/package/@bdsqqq/lazytm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
