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

    Function createScope

    Creates a new Scope, optionally mapping each allocated id.

    • Creates a new Scope.

      Ids start at 0 and increment monotonically, so all ids the scope hands out are pairwise distinct.

      Returns Scope

      A fresh, immutable scope handing out numeric ids

    • Creates a new Scope with mapped values.

      Ids start at 0 and increment monotonically, so all ids the scope hands out are pairwise distinct; each is passed through mapper to produce the value returned. mapper runs once per id and its result is cached, so a repeat keyed lookup returns the same value (the same reference when mapper produces objects) without re-invoking it.

      Type Parameters

      • T

        The mapped value type

      Parameters

      • mapper: (index: number) => T

        Maps each monotonic id to the value handed out by the scope; invoked once per id

      Returns Scope<T>

      A fresh, immutable scope handing out mapped values