Type alias IsomorphicIterable<Item>

IsomorphicIterable<Item>: ReadOnly<AsyncIterable<Item> | Iterable<Item>>

Value might be an AsyncIterable or just an Iterable.

Remarks

Union type useful when you want to accept both AsyncIterable and Iterable values, which is generally in asynchronous functions that can loop over @@asyncIterator or @@iterator values.

Example

const iterable: IsomorphicIterable<number> = [1, 2, 3];

for (const item of iterable) {
console.log(item); // Works
}

for await (const item of iterable) {
console.log(item); // Also works
}

See

Type Parameters

  • Item = unknown

    Type of the items in the iterable.