ByteLengthQueuingStrategy: size() method

Note: This feature is available in Web Workers.

The size() method of the ByteLengthQueuingStrategy interface returns the given chunk's byteLength property.

Syntax

js
size(chunk)

Parameters

chunk

A chunk of data being passed through the stream.

Return value

An integer representing the byte length of the given chunk.

Examples

js
const queuingStrategy = new ByteLengthQueuingStrategy({ highWaterMark: 1 });

const readableStream = new ReadableStream(
  {
    start(controller) {
      // …
    },
    pull(controller) {
      // …
    },
    cancel(err) {
      console.log("stream error:", err);
    },
  },
  queuingStrategy,
);

const size = queueingStrategy.size(chunk);

Specifications

Specification
Streams Standard
# blqs-size

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
size

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also