Provides Scope, a counter that hands out unique sequential ids. Each id is cached against a
caller-supplied key, compared by reference identity, so repeated lookups of the same key resolve to
the same value without a string proxy.
By default createScope builds a scope handing out raw numeric ids; given a mapper, each id
is passed through it to produce the value returned instead.
scope.resolve(node); // 0 (fresh id bound to node) scope.resolve(node); // 0 (cached hit on the same reference) scope.resolve({}); // 1 (distinct reference, fresh id) scope.resolve(); // 2 (anonymous, always fresh)
Passing a mapper derives a value from each id, caching it and returning it again for repeated keys:
Identity-keyed value allocation.
Provides Scope, a counter that hands out unique sequential ids. Each id is cached against a caller-supplied key, compared by reference identity, so repeated lookups of the same key resolve to the same value without a string proxy.
By default createScope builds a scope handing out raw numeric ids; given a mapper, each id is passed through it to produce the value returned instead.
Passing a mapper derives a value from each id, caching it and returning it again for repeated keys: