@public-function/unique-promise
v1.0.1
Published
Group promises by id and execute only one at a time.
Downloads
12
Readme
Unique Promise
A typical use case would be some express routes that resolve database queries that should only be called once and respond with the same result to all requests.
import uniquePromise from '@public-function/unqiue-promise';
const executeLongRunningFunction = async () => {
// is only called once
}
const results = await Promise.all([
uniquePromise('some-id', executeLongRunningFunction),
uniquePromise('some-id', executeLongRunningFunction),
]);