Skip to main content

Core module · streaming API

Iterator utilities

Use one async-iteration model for readable and writable streams in browser and Node.js code.

The stream boundary

Treat arriving data as an async sequence.

The iterator helper lets loaders and application code consume or produce chunks without depending on the stream implementation underneath.

Readable

Iterate chunks from a stream

Writable

Write chunks through an async iterator

Runtime

Works in browsers and Node.js

Use

Streaming loaders, writers, and transforms

Detailed guide

Iterator utility reference

The section below documents the stream-to-iterator helper.

Functions​

The public core helpers are makeIterator and makeStream:

import {makeIterator, makeStream} from '@loaders.gl/core';

const iterator = makeIterator(response);
for await (const chunk of iterator) {
processChunk(chunk);
}

makeIterator adapts loaded data, responses, blobs, and supported readable streams to a chunk iterator. makeStream wraps an iterator in a readable stream. These helpers read data; they do not turn a writable stream into a readable iterator.