method

ReadableStreamDirectController.write

data: string | BufferSource
): number | Promise<number>;

Write a chunk directly to the destination.

Returns the number of bytes written, or a pending Promise<number> when the destination's internal buffer is full (backpressure). The chunk was accepted either way; awaiting the result is enough:

await controller.write(chunk);

The promise resolves once the destination has drained. await controller.flush(true) is equivalent.

Referenced types

type BufferSource =
| NodeJS.TypedArray<ArrayBufferLike>
| DataView<ArrayBufferLike>
| ArrayBufferLike