Resolve a promise after specified timeout
To use this package, you only need to install this dependency, import it and invoke the sleep
function, e.g.:
import { sleep } from '@lukaspolak/sleep'
// async/await syntax
const asyncFn = async () => {
await sleep(500) // Promise will be resolved in 500ms
//...
}
// then syntax
sleep(500).then(() => {
// ...
})
npm install @lukaspolak/sleep
or
yarn add @lukaspolak/sleep
Please read the Contribution guidelines to start with your awesome contributions!
There are a lot of similar libraries/packages on GitHub and npm, that can do the same. I wanted to enhance my programming skills, and I didn't want to find a unique name for the package.