1.1.0 • Published 5 years ago
@react-corekit/sleep v1.1.0
@react-corekit/sleep
Non blocking asynchronous sleep. Due the nature of javascript an the event loop, it suspends the current function execution only. It does not pause the entire program execution.
Install
npm install --save @react-corekit/sleep
yarn add @react-corekit/sleep
Syntax
await sleep(n);
// Do something
sleep(n).then(() => {
// Do something
});
Usage
import sleep from '@react-corekit/sleep';
async function run() {
/* wait one second before
contitue this function execution */
await sleep(1000);
}
run();
Additional documentation
Async functions - making promises friendly
License
MIT © glongh