丢弃最旧的
🌐 Drop-oldest
写入操作从不等待。当槽缓冲区已满时,最旧的缓冲块会被清除,以为即将写入的数据腾出空间。消费者始终看到最新的数据。适用于实时信息流、遥测或任何陈旧数据价值低于当前数据的场景。
🌐 Writes never wait. When the slots buffer is full, the oldest buffered chunk is evicted to make room for the incoming write. The consumer always sees the most recent data. Useful for live feeds, telemetry, or any scenario where stale data is less valuable than current data.
import { push } from 'node:stream/iter';
// Keep only the 5 most recent readings
const { writer, readable } = push({
highWaterMark: 5,
backpressure: 'drop-oldest',
});const { push } = require('node:stream/iter');
// Keep only the 5 most recent readings
const { writer, readable } = push({
highWaterMark: 5,
backpressure: 'drop-oldest',
});