README
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
Promise
⏏
sleep(ms, [returnValue]) ⇒ 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>.