2.1.2 • Published 11 months ago

sleep-anywhere v2.1.2

Weekly downloads
8
License
MIT
Repository
github
Last release
11 months ago

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

sleep-anywhere

An isomorphic sleep function you can use anywhere. Only required in the browser or isomorphic code - if your code runs on NodeJs only use this instead:

import { setTimeout as sleep } from 'node:timers/promises'

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

ParamTypeDescription
msnumberHow 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-24 Lloyd Brookes \75pound@gmail.com\.

2.1.2

11 months ago

2.1.1

3 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

7 years ago

0.1.0

7 years ago