TransformStreamDefaultController.enqueue()

The enqueue() method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.

For more information on readable streams and chunks see Using Readable Streams.

Syntax

TransformStreamDefaultController.enqueue(chunk);

Parameters

chunk

The chunk being queued. A chunk is a single piece of data. It can be any type of data, and a stream can contain chunks of different types.

Examples

In this example an encoded chunk is passed to the queue using the enqueue() method.

const textEncoderStream = new TransformStream({
  transform(chunk, controller) {
    controller.enqueue(new TextEncoder().encode(chunk));
  },
  flush(controller) {
    controller.terminate();
  },
});

Specifications

Specification
Streams Standard
# ts-default-controller-enqueue

Browser compatibility

BCD tables only load in the browser