wait
: A Promise
-based delay.
npm i @sharyn/util.wait
# or
yarn add @sharyn/util.wait
You can alternatively install the @sharyn/util package, or the entire sharyn library.
[milliseconds=1000] (number): The duration of the wait.
Promise
const main = async () => {
console.log('Legen - wait for it...')
await wait(3000)
console.log('...dary!')
}
main()
Depending on the package you are using, you can import
or require
wait
in the following ways:
// If you installed @sharyn/util.wait
import wait from '@sharyn/util.wait' // smaller size, better for client bundles
// If you installed @sharyn/util
import wait from '@sharyn/util/wait' // smaller size, better for client bundles
import { wait } from '@sharyn/util' // more convenient in Node environments
// If you installed sharyn
import wait from 'sharyn/util/wait' // smaller size, better for client bundles
import { wait } from 'sharyn/util' // more convenient in Node environments
This package is part of Sharyn, a collection of utilities and helpers.