The value type.
The key type.
The value type.
Optional
entries: readonly (readonly [K, V])[]Initial entries for the map.
The number of entries currently in the map. This is a snapshot; the results of any pending actions will not be visible yet.
Deletes all entries. If there are no pending actions for a key its entry will be deleted immediately. Otherwise its entry will only be deleted until all pending actions have finished.
A promise that will be resolved once every entry has been deleted.
The promise will not be resolved until all current entries have been removed once; at that time new entries may have been added though. The promise will never be rejected.
Computes the value for a key. The new value will be the return value of calling the given function. If the given function throws an error, the error is propagated through the returned promise and no value is set or removed.
The key to compute the value for.
The function to compute the value. Its input will be the key and previous value, or undefined
if there was no entry yet.
Optional
v: VA promise that will be resolved with the new value for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will be rejected if the given function throws an error.
Computes the value for a key.
The new value will be the return value of calling the given function. However, if the given function returns undefined
, any existing entry is removed instead.
If the given function throws an error, the error is propagated through the returned promise and no value is set or removed.
The key to compute the value for.
The function to compute the value. Its input will be the key and previous value, or undefined
if there was no entry yet.
Optional
v: VA promise that will be resolved with the new value for the key, or undefined
if the given function returns undefined
.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will be rejected if the given function throws an error.
Computes the value for a key only if there is no entry for the key yet. The new value will be the return value of calling the given function. If the given function throws an error, the error is propagated through the returned promise and no value is set.
The key to compute the value for.
The function to compute the value. Its input will be the key.
A promise that will be resolved with the new value for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will be rejected if the given function throws an error.
Computes the value for a key only if there is no entry for the key yet.
The new value will be the return value of calling the given function. However, if the given function returns undefined
, no value is set.
If the given function throws an error, the error is propagated through the returned promise and no value is set.
The key to compute the value for.
The function to compute the value. Its input will be the key.
A promise that will be resolved with the new value for the key, or undefined
if the given function returns undefined
.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will be rejected if the given function throws an error.
Computes the value for a key only if there is entry for the key already.
The new value will be the return value of calling the given function. However, if the given function returns undefined
, the entry is removed instead.
If the given function throws an error, the error is propagated through the returned promise and no value is set or removed.
The key to compute the value for.
The function to compute the value. Its input will be the key and previous value.
A promise that will be resolved with the new value for the key, or undefined
if there was no entry for the given key or if the given function returns undefined
.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will be rejected if the given function throws an error.
Deletes the entry for a key.
The key to delete the entry for.
A promise that will be resolved with the previous value for the key, or undefined
if there was no entry for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will never be rejected.
Deletes the entry for a key only if it's currently mapped to a given value.
The key to delete the entry for.
The value for the key.
A promise that will be resolved with true
if the entry was deleted, or false
otherwise.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will never be rejected.
Executes a given callback on each entry. This is a snapshot; the results of any pending actions will not be visible yet.
The function to call for each entry. Its arguments will be the value, key and this map.
Returns the value for a key, if available.
The key to return the value for.
A promise that will be resolved with the value for the key, or undefined
if there is no entry for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will never be rejected.
Sets the value for a key, merging it with any existing value if necessary. If there was no entry yet for the key, its value will be set to the given value. Otherwise, the new value will be the return value of calling the given function. If the given function throws an error, the error is propagated through the returned promise and no value is set or removed.
The key to compute the value for.
The function to compute the value. Its input will be the previous value and the given value.
A promise that will be resolved with the new value for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will be rejected if the given function throws an error.
Sets the value for a key, merging it with any existing value if necessary.
If there was no entry yet for the key, its value will be set to the given value. Otherwise, the new value will be the return value of calling the given function.
However, if the given function returns undefined
, the entry is removed instead.
If the given function throws an error, the error is propagated through the returned promise and no value is set or removed.
The key to compute the value for.
The function to compute the value. Its input will be the previous value and the given value.
A promise that will be resolved with the new value for the key, or undefined
if the given function returns undefined
.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will be rejected if the given function throws an error.
Sets the value for a key only if it is currently mapped to a given value. This is similar to setIfPresent, except this method will only replace the given value.
The key to set the value for.
The value to replace.
The new value to set.
A promise that will be resolved with true
if the key was previously mapped to the given value, or false
otherwise.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will never be rejected.
Sets the value for a key.
The key to set the value for.
The value to set.
A promise that will be resolved with the previous value for the key, or undefined
if there was no entry for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will never be rejected.
Sets the value for a key only if there is no entry for the key yet.
The key to set the value for.
The value to set.
A promise that will be resolved with the previous value for the key, or undefined
if there was no entry for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will never be rejected.
Sets the value for a key only if there is an entry for the key already. This is similar to replace, except this method will replace any existing value.
The key to set the value for.
The value to set.
A promise that will be resolved with the previous value for the key, or undefined
if there was no entry for the key.
If there are any pending actions for the key the returned promise will not be resolved until they have all finished. The promise will never be rejected.
The key type.