@bytesoftio/helpers-promises
Installation
yarn add @bytesoftio/helpers-promises
or npm install @bytesoftio/helpers-promises
Table of contents
Description
A collection of promises related helpers.
createTimeout
A promisified verion of the setTimeout
function.
import { createTimeout } from "@bytesoftio/helpers-promises"
await createTimeout(2000)
createPromise
Create a promise that you can pass around without specifying the resolve function first.
import { createPromise } from "@bytesoftio/helpers-promises"
const promise = createPromise()
// pass promise to another function
runWhenResolved(promise)
promise.resolve("your data")
// or
promise.reject("reason...")