# extra-generator

> ```sh npm install --save extra-generator # or yarn add extra-generator ```

Latest version **0.7.1** (published 2026-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install extra-generator
pnpm add extra-generator
yarn add extra-generator
bun add extra-generator
```

## Health

**Score 60/100 (C)** — status: stable.

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2026-02-17 |
| First published | 2021-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 2 |
| Unpacked size | 45.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlackGlory |
| Maintainers | black_glory |
| Keywords | Iterable, AsyncIterable, of, countdown, countup, range |

## Links

- npm: https://www.npmjs.com/package/extra-generator
- Repository: https://github.com/BlackGlory/extra-generator
- Homepage: https://github.com/BlackGlory/extra-generator#readme
- Issues: https://github.com/BlackGlory/extra-generator/issues
- npm.io page: https://npm.io/package/extra-generator

## Dependencies (2)

- [return-style](https://npm.io/package/return-style.md) ^3.0.1
- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.4.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.7.1 (latest) — 2026-02-17
- 0.7.0 — 2026-02-16
- 0.6.0 — 2026-02-15
- 0.5.9 — 2024-08-16
- 0.5.8 — 2024-06-13
- 0.5.7 — 2024-05-16
- 0.5.6 — 2024-05-13
- 0.5.5 — 2024-04-26
- 0.5.4 — 2024-01-31
- 0.5.3 — 2023-08-11
- 0.5.2 — 2023-08-11
- 0.5.1 — 2023-06-10
- 0.5.0 — 2023-05-04
- 0.4.0 — 2023-03-18
- 0.3.3 — 2023-01-28
- … 34 more at https://npm.io/package/extra-generator/versions

## README

# extra-generator
## Install
```sh
npm install --save extra-generator
# or
yarn add extra-generator
```

## API
### handleYieldedValues
```ts
function handleYieldedValues<T, Return, Next>(
  generator: Generator<T, Return, Next>
, fn: (value: T, index: number) => Next
): Return
```

### handleYieldedValuesAsync
```ts
function handleYieldedValuesAsync<T, Return, Next>(
  generator: Generator<T, Return, Next>
, fn: (value: T, index: number) => PromiseLike<Next>
): Promise<Return>
function handleYieldedValuesAsync<T, Return, Next>(
  generator: AsyncGenerator<T, Return, Next>
, fn: (value: T, index: number) => Awaitable<Next>
): Promise<Return>
```

### of
```ts
function of<T>(val: T): IterableIterator<T>
```

```js
of(1) // [1]
```

### repeat
```ts
function repeat<T>(val: T, times: number = Infinity): IterableIterator<T>
```

```js
repeat(1) // [1, 1, 1, ...]
repeat(1, 3) // [1, 1, 1]
repeat(1, 0) // []
```

### spawn
```ts
function spawn<T>(create: (num: number) => T, times: number = Infinity): IterableIterator<T>
```

```js
spawn(x => x * 2) // [2, 4, 6, ...]
spawn(x => x * 2, 3) // [2, 4, 6]
spawn(x => x * 2, 0) // []
```

### countdown
```ts
function countdown(begin: number, end: number): IterableIterator<number>
```

```js
countdown(2, -2) // [2, 1, 0, -1, -2]
countdown(1, 1) // [1]
countdown(0, 1) // []
```

### countup
```ts
function countup(begin: number, end: number): IterableIterator<number>
```

```js
countup(-2, 2) // [-2, -1, 0, 1, 2]
countup(1, 1) // [1]
countup(1, 0) // []
```

### range
```ts
function range(
  start: number
, end: number
, step: number = 1 // step > 0
, inclusive: boolean = false
): IterableIterator<number>
```

This iterator is essentially a variant of the for loop.

```js
range(1, 1) // []
range(-1, 1) // [-1, 0]
range(-1, 1, true) // [-1, 0, 1]
range(1, -1, 0.5) // [1, 0.5, 0, -0.5]
range(1, -1, 0.75) // [1, 0.25, -0.5]
```

### stringifyJSONStream
```ts
function stringifyJSONStream<T>(iterable: Iterable<T>): Iterable<string>
```

### stringifyJSONStreamAsync
```ts
function stringifyNDJSONStreamAsync<T>(iterable: AsyncIterable<T>): AsyncIterable<string>
```

### stringifyNDJSONStream
```ts
function stringifyNDJSONStream<T>(iterable: Iterable<T>): Iterable<string>
```

### stringifyNDJSONStreamAsync
```ts
function stringifyNDJSONStreamAsync<T>(iterable: AsyncIterable<T>): AsyncIterable<string>
```

### timestampBasedId
```ts
function timestampBasedId(): Iterator<[timestamp: number, num: number]>
```

### ContinuableIterable
```ts
interface IContinuableIterable<T> extends Iterable<T> {
  close(): void
}

class ContinuableIterable<T> implements IContinuableIterable<T> {
  get done(): boolean | undefined

  constructor(iterable: Iterable<T>)

  close(): void
}
```

### ContinuableAsyncIterable
```ts
interface IContinuableAsyncIterable<T> extends AsyncIterable<T> {
  close(): Promise<void>
}

class ContinuableAsyncIterable<T> implements IContinuableAsyncIterable<T> {
  get done(): boolean | undefined

  constructor(iterable: AsyncIterable<T>)

  close(): Promise<void>
}
```

### ngrams
```ts
function ngrams(text: string, n: number): IterableIterator<string>
```

### allNgrams
```ts
function allNgrams(text: string): IterableIterator<string>
```

### allCombinations
```ts
function allCombinations<T>(arr: T[], k: number): IterableIterator<T[]>
```

### allIndexCombinations
```ts
function allIndexCombinations(
  arr: unknown[]
, k: number
): IterableIterator<number[]>
```

### positiveFactors
```ts
function positiveFactors(value: number): IterableIterator<number>
```

```ts
positiveFactors(0) // []
positiveFactors(10) // [10, 5, 2, 1]
positiveFactors(-10) // [10, 5, 2, 1]
```

### positiveCommonDivisors
```ts
function positiveCommonDivisors(a: number, b: number): IterableIterator<number>
```

```ts
positiveCommonDivisors(0, 0) // []
positiveCommonDivisors(4, 0) // [4, 2, 1]
positiveCommonDivisors(12, 8) // [4, 2, 1]
positiveCommonDivisors(-12, 8) // [4, 2, 1]
```

### reverse
```ts
function reverse<T>(arr: ArrayLike<T>): IterableIterator<T>
```

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