MDN self-hosted library · e01.org

WritableStreamDefaultWriter: desiredSize property

Streams

Open notebook · 1 cells web-api-instance-property upstream source

Streams

The desiredSize read-only property of the WritableStreamDefaultWriter interface returns the desired size required to fill the stream's internal queue.

Value

A number, or null.

The number can be negative if the queue is over-full. When a custom queuing strategy is used, its chunk sizes can cause the number to have a fractional component. The value is null if the stream is erroring or errored, and 0 if it is closed.

Exceptions

  • TypeError
  • : The writer's lock is released.

Examples

const writableStream = new WritableStream(
  {
    write(chunk) {
      // …
    },
    close() {
      // …
    },
    abort(err) {
      // …
    },
  },
  queuingStrategy,
);

// …

const writer = writableStream.getWriter();

// …

// return stream's desired size
const size = writer.desiredSize;

Specifications

Browser compatibility