Constructor
new ReusablePromiseMap(configuration)
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
configuration |
object |
Properties
|
- Source:
Classes
Methods
(async) callByKey(key, createPromise) → {Promise.<T>}
Checks if a promise with the supplied key exists, if so, `await`s it, otherwise sets a new `Promise` produced by
calling `createPromise` function.
In case capacity is reached, the current call will be paused until the next promise(s) is resolved.
Parameters:
Name | Type | Description |
---|---|---|
key |
* | |
createPromise |
function |
- Source:
Returns:
- Type
- Promise.<T>
clear()
Clears the underlying `Promise` map and `reject`s all queued items.
- Source:
reachedCapacity() → {boolean}
Returns `true` if capacity is reached.
- Source:
Returns:
- Type
- boolean
shiftQueuedItems(limit, fopt)
Shifts up to `limit` items from the queue applying the supplied function to each.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number | |||
f |
function |
<optional> |
({ resolve, reject: _ }) => resolve() |
- Source: