CountQueuingStrategy: size() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Streams")}}{{AvailableInWorkers}}

The **size()** method of the {{domxref("CountQueuingStrategy")}} interface always returns 1, so that the total queue size is a count of the number of chunks in the queue.

Syntax

js-nolint
size()

Parameters

None.

Return value

1.

Examples

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

const writableStream = new WritableStream(
  {
    // Implement the sink
    write(chunk) {
      // …
    },
    close() {
      // …
    },
    abort(err) {
      console.log("Sink error:", err);
    },
  },
  queuingStrategy,
);

const size = queuingStrategy.size();

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("CountQueuingStrategy.CountQueuingStrategy", "CountQueuingStrategy()")}} constructor