The number of elements in the Dictionary.
Creates an iterator over the Dictionary's key-value pairs.
Enables the Dictionary to be iterable directly.
An iterator of the Dictionary's key-value pairs.
Removes all entries from this Dictionary.
Removes the entry with key from the Dictionary if it exists.
The key of the entry to remove from the Dictionary.
true if the Dictionary contained an entry with key key,
otherwise false.
const { containers } = createFutureMachine(futureDatabase);
const dictionary = containers.dictionary.create<number>([
['hello', 1],
['world', 2],
]);
console.log(dictionary.delete('world'));
console.log(dictionary.delete('fizz'));
// `dictionary` now contains these entries:
// hello: 1
//
// Console output:
// true
// false
Creates an iterator over the Dictionary's key-value pairs.
An iterator of the Dictionary's key-value pairs.
Gets the value of the entry whose key is key.
The key of the entry whose value we're retrieving.
The value of the entry with key key or undefined if no entry has
key key.
Gets or inserts the value of the entry whose key is key. If no entry with
key exists, then an entry is inserted with key and value value first
before returning its value.
The key of the entry whose value we're returning.
The value to insert in the case that an entry with key key
doesn't already exist.
The value of the existing or newly inserted entry with key key.
Gets or inserts the value of the entry whose key is key. If no entry with
key exists, then an entry is inserted with key key and a value computed
by callback before returning its value.
The value of the existing or newly inserted entry with key key.
const { containers } = createFutureMachine(futureDatabase);
const dictionary = containers.dictionary.create<number>([
['hello', 1],
['world', 2],
]);
console.log(dictionary.getOrInsertComputed('world', () => 3));
console.log(dictionary.getOrInsertComputed('fizz', (key: string) => key.length));
// Console output:
// 2
// 4
Returns whether the Dictionary contains an entry with key key.
The key of the entry to look up if it exists.
true if the Dictionary contains an entry with key key,
otherwise false.
Creates an iterator over the Dictionary's keys.
An iterator of the Dictionary's keys.
Inserts a new entry whose key is key and value is value.
The key of the new entry.
The value of the new entry.
This Dictionary.
Creates an iterator over the Dictionary's values.
An iterator of the Dictionary's values.
A container that stores and retrieves values by key.
The Serializable equivalent of a vanilla JavaScript
Map.