API · Flow

throttle()

Emit the leading value, then drop values arriving before the configured interval expires.

Signature

throttle(milliseconds: number): Exstream<T, C>

Example

const snapshots = metrics.throttle(1_000)

Parameters

milliseconds

Type non-negative finite numberRequired

Minimum elapsed monotonic time between emitted successful values.

Behavior

The first value is emitted immediately. The window is measured from the last emitted value. Later values inside it are discarded; there is no trailing emission and nothing is delayed. throttle(0) keeps every value.

Order and context are preserved for retained values. Because dropped values are consumed immediately, this operator does not slow or backpressure a hot producer beyond normal downstream pressure on retained values. It has constant memory. Existing record errors pass through and do not reset the timer.

Errors

Negative values, NaN, and Infinity are rejected at construction. Numeric strings are coerced at runtime but are outside the TypeScript contract.

Forms

stream.throttle(1_000)
exstream.pipeline().throttle(1_000)
exstream.throttle(1_000, stream)
stream.through(exstream.throttle(1_000))

ratelimit(), makeAsync(), observe()