sleep-anywhere

A sleep function you can use anywhere

Usage no npm install needed!

<script type="module">
  import sleepAnywhere from 'https://cdn.skypack.dev/sleep-anywhere';
</script>

README

view on npm npm module downloads Gihub repo dependents Gihub package dependents Node.js CI js-standard-style

sleep-anywhere

A sleep function you can use anywhere.

Example

import sleep from 'sleep-anywhere'

const result = await sleep(5000, 'later')
console.log('5s', result)
// 5s later

sleep(ms, [returnValue]) ⇒ Promise

Returns a promise which fulfils after ms milliseconds with the supplied returnValue.

Kind: Exported function

Param Type Description
ms number How long in milliseconds to sleep for.
[returnValue] * The value to return.

Load anywhere

This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.

Node.js CommonJS:

const sleep = require('sleep-anywhere')

Node.js ECMAScript Module:

import sleep from 'sleep-anywhere'

Within a modern browser ECMAScript Module:

import sleep from './node_modules/sleep-anywhere/index.js'

© 2018-21 Lloyd Brookes <75pound@gmail.com>.