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 (unique 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:
edges.resolve(from, to); // 0 (fresh id bound to the pair) edges.resolve(from, to); // 0 (cached hit on the same pair) edges.resolve(to, from); // 1 (order matters)
Unique 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:
Passing several keys forms a composite: the value is shared only when every component matches by reference, in the same order.