Skip to content

WritableStream ​

WritableStream<T> is a write-only capability returned by native adapters such as file writes and child-process input.

SignatureWritableStream<T>

Methods ​

MethodSignaturePurpose
write(value: T) => Promise<void>Waits until the bounded queue accepts one value.
close() => Promise<void>Finishes accepted writes and closes the writable side.

Usage ​

tyrus
async function produce(stream: WritableStream<u8[]>, bytes: u8[]): Promise<void> {
    await stream.write(bytes);
    await stream.close();
}

error

tyrus
async function invalid(writable: WritableStream<u8[]>): Promise<void> {
const text: string = "not bytes";
await writable.write(text); 
}

Errors ​

write() rejects with StreamError for a closed, failed, or concurrently used stream, and immediately rejects a binary chunk larger than the buffer capacity. close() is idempotent.