Class

LimitedCollection

Collection with optional FIFO eviction when a new key is inserted at capacity. Construction is Map-safe: options are never passed to `super()`, so subclasses can call `super({ maxSize, onEvict })` without Map treating the options object as an iterable.

Extends Collection

Constructor

new LimitedCollection(options: LimitedCollectionOptions<, >)
ParamTypeDescription
optionsLimitedCollectionOptions<, >

Properties

bounded: boolean (readonly)

Whether this collection enforces a finite capacity.

maxSize: number (readonly)
onEvict: ((key: , value: ) => void) | null (readonly)

Methods

clone(): LimitedCollection<, >

Clone into a new LimitedCollection with the same limits (no `onEvict` callback).

set(key: , value: ): this

Insert or update an entry. When at capacity and `key` is new, the oldest entry is removed (FIFO by Map insertion order) and `onEvict` is invoked if set.

ParamTypeDescription
keyK
valueV
sweep(filter?: (value: , key: ) => boolean): number

Remove entries matching `filter` (or all if omitted). Returns count removed. Does not invoke `onEvict` — callers that need cascade teardown should handle it.

ParamTypeDescription
filter?(value: , key: ) => boolean