FuzzyMap
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:39
A map whose keys match after a caller-supplied normalisation.
Case-insensitive lookup, accent folding, whitespace collapsing, phonetic keys
— all the same structure with a different function, rather than one class per
normalisation strategy. normalize is applied to every key on the way in and
to every query on the way out; whatever it maps together is together.
The first key to claim a normalised slot is the one keys() reports, and
a later set under an equivalent key updates the value without replacing the
stored key. So a map normalising by lower case, given "Foo" then "FOO",
holds one entry keyed "Foo" — the original spelling survives, which is what
makes it usable for display.
Time complexity: O(1) plus the cost of normalize, for every operation.
Type Parameters
Section titled “Type Parameters”K
The key type as callers see it.
V extends DefinedValue
The value type.
Implements
Section titled “Implements”IMap<K,V>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FuzzyMap<
K,V>(iterable,options):FuzzyMap<K,V>
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:43
Parameters
Section titled “Parameters”iterable
Section titled “iterable”Iterable<readonly [K, V], any, any> | undefined
options
Section titled “options”Returns
Section titled “Returns”FuzzyMap<K, V>
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<readonly [K,V]>
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:56
Returns
Section titled “Returns”Iterator<readonly [K, V]>
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:64
Removes all elements from the collection.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”count()
Section titled “count()”count():
number
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:60
The number of elements in the collection.
A method, not a getter: its async counterpart needs a round trip to the backing store, and a member must have the same shape in both.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”delete()
Section titled “delete()”delete(
key):boolean
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:91
O(1) plus normalize.
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”entries()
Section titled “entries()”entries():
IterableIterator<readonly [K,V]>
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:110
In first-insertion order, each key in its original form.
Returns
Section titled “Returns”IterableIterator<readonly [K, V]>
Implementation of
Section titled “Implementation of”get(
key):V|undefined
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:69
O(1) plus normalize.
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”V | undefined
Implementation of
Section titled “Implementation of”has(
key):boolean
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:86
O(1) plus normalize.
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”keys()
Section titled “keys()”keys():
IterableIterator<K>
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:96
The stored keys, in their original form, in first-insertion order.
Returns
Section titled “Returns”IterableIterator<K>
Implementation of
Section titled “Implementation of”set(
key,value):void
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:74
O(1) plus normalize. Keeps the key already stored, if any.
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”storedKey()
Section titled “storedKey()”storedKey(
key):K|undefined
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:122
The key actually stored for whatever key normalises to.
Answers “which spelling won” without going through keys(): the stored key
and the query can differ, which is the whole point of this type.
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”K | undefined
values()
Section titled “values()”values():
IterableIterator<V>
Defined in: packages/data/src/fuzzy/fuzzy-map.ts:103
In first-insertion order.
Returns
Section titled “Returns”IterableIterator<V>