@metreeca/core - v0.9.19
    Preparing search index...

    Type Alias Scope<T>

    Identity-keyed value allocation scope.

    Hands out unique sequential ids, each returned as a value of type T derived from it and cached against an optional key matched by Map key equality (SameValueZero). A keyed call returns the cached value on a repeat hit (the same reference when T is an object); an unkeyed call always allocates a fresh anonymous id. Keyed and anonymous allocations share one monotonic counter, so every id is unique within the scope.

    Important

    Keys match by reference, not structure: two equal-looking object literals are distinct keys. This is what keeps values consistent across multi-pass operations: every pass that revisits the same node resolves to the same value. Callers wanting coordinated values must thread the one node object through every pass, never rebuild an equal-looking key.

    type Scope<T = number> = {
        resolve(key?: unknown): T;
    }

    Type Parameters

    • T = number

      The value handed out per allocation, derived from each numeric id; defaults to number

    Index

    Methods

    Methods

    • Resolves the value bound to key, allocating it on first lookup.

      Parameters

      • Optionalkey: unknown

        Cache key matched by reference identity; omit to allocate a fresh anonymous value

      Returns T

      The value cached for key, allocated on first lookup and returned unchanged thereafter; a freshly allocated value when key is omitted or not yet bound