exportdefaultclassArrayStreamer<T = unknown> extendsStreamer<StreamedArray<T>> { /** * Index of the current streamed array element */ protectedindex: number = 0;
/** @inheritDoc */ protectedcheckToken(chunk: Token): boolean { if (chunk.name !== 'startArray') { thrownewTypeError('The top-level object should be an array'); }
core/json/stream/streamers
This module provides a bunch of classes to stream object or array elements. Also, the module provides an abstract class to create your own streamers
Usage
Streamers
ObjectStreamer
An instance of the ObjectStreamer class takes an iterable object of parsed tokens of some object and yields assembled elements of this object.
ArrayStreamer
An instance of ArrayStreamer ObjectStreamer class takes an iterable object of parsed tokens of some array and yields assembled elements of this array.
AbstractStreamer
When creating a new streamer class, extend it from the
AbstractStreamer
and implement thecheckToken
andpush
methods.API
constructor
The instance constructor takes one optional parameter. It is an object with parameters for a token [[Assembler]].
processToken
Processes the passed JSON token and yields values.