@sharyn/util.wait

wait: A Promise-based delay.

Usage no npm install needed!

<script type="module">
  import sharynUtilWait from 'https://cdn.skypack.dev/@sharyn/util.wait';
</script>

README

🌹 wait

wait: A Promise-based delay.

Installation

npm i @sharyn/util.wait
# or
yarn add @sharyn/util.wait

You can alternatively install the @sharyn/util package, or the entire sharyn library.

Arguments

[milliseconds=1000] (number): The duration of the wait.

Returns

Promise

Example

const main = async () => {
  console.log('Legen - wait for it...')
  await wait(3000)
  console.log('...dary!')
}

main()

Imports

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.