CountQueuingStrategy

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.

Giao diện CountQueuingStrategy của Streams API cung cấp một chiến lược xếp hàng đếm chunk dựng sẵn, có thể được dùng khi khởi tạo stream.

Bộ khởi tạo

CountQueuingStrategy()

Tạo một thể hiện đối tượng CountQueuingStrategy mới.

Thuộc tính thể hiện

CountQueuingStrategy.highWaterMark Read only

Tổng số chunk có thể được chứa trong hàng đợi nội bộ trước khi backpressure được áp dụng.

Phương thức thể hiện

CountQueuingStrategy.size()

Luôn trả về 1.

Ví dụ

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

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

const size = queueingStrategy.size();

Thông số kỹ thuật

Specification
Streams
# cqs-class

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

Xem thêm