Skip to content

Function: createReplayBuffer()

createReplayBuffer<T>(capacity): ReplayBuffer<T>

Defined in: primitives/buffer.ts:470

Creates a replay buffer with a specified capacity. This buffer stores a history of values up to its capacity and allows new readers to "replay" past values from the point they attach, up to the current value.

If capacity is Infinity, it acts as an unbounded replay buffer, storing all values. Otherwise, it's a fixed-size circular buffer.

Type Parameters

T

T = any

The type of the values in the buffer.

Parameters

capacity

number

The maximum number of past values to buffer. Use Infinity for an unbounded buffer.

Returns

ReplayBuffer<T>

An object representing the replay buffer.

Released under the MIT License.