Skip to content

Function.lazyChunk

github-actions[bot] edited this page Nov 18, 2026 · 13 revisions

umt / lazyChunk

Function: lazyChunk()

lazyChunk<T>(iterable, size): Generator<T[], void, undefined>

Defined in: Iterator/lazyChunk.ts:11

Lazily groups values from an iterable into arrays of the given size The last chunk holds the remaining values and may be shorter than size.

Type Parameters

T

T

Parameters

iterable

Iterable<T>

The source iterable

size

number

The number of values in each chunk

Returns

Generator<T[], void, undefined>

A generator yielding chunks

Example

const chunks = lazyChunk([1, 2, 3, 4, 5], 2);
[...chunks]; // [[1, 2], [3, 4], [5]]

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally