@react-corekit/sleep

1.1.0 • Public • Published

@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.

NPM

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

The setTimeout() method

Async functions - making promises friendly

The basics of async/await

License

MIT © glongh

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    34
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    34
  • 1.0.0
    0

Package Sidebar

Install

npm i @react-corekit/sleep

Weekly Downloads

34

Version

1.1.0

License

MIT

Unpacked Size

2.88 kB

Total Files

5

Last publish

Collaborators

  • glongh