CountQueuingStrategy: phương thức size()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2019.

Note: This feature is available in Web Workers.

Phương thức size() của giao diện CountQueuingStrategy luôn trả về 1, để tổng kích thước hàng đợi là số lượng chunk trong hàng đợi.

Cú pháp

js
size()

Tham số

Không có.

Giá trị trả về

1.

Ví dụ

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();

Thông số kỹ thuật

Thông số kỹ thuật
Streams
# ref-for-cqs-size②

Khả năng tương thích với trình duyệt

Xem thêm