@you21979/promise-sleep
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

node-promise-sleep

very simple implementation.

install

npm i @you21979/promise-sleep

usage

simple

const sleep = require('@you21979/promise-sleep');
sleep(1000, "test data").
  then( res => sleep(2000, res)).
  then( res => sleep(3000, res)).
  then( res => sleep(4000, res)).
  then( res => console.log(res))

loop

const sleep = require('@you21979/promise-sleep');

const update = (msec, x) => {

    if(x >= 10){
        return;
    }

    console.log(x);

    sleep(msec, x).then((x) => update(msec, x + 1))
}

const main = () => {
    update(1000, 0)
}

main();

Readme

Keywords

Package Sidebar

Install

npm i @you21979/promise-sleep

Weekly Downloads

32

Version

1.1.2

License

MIT

Unpacked Size

7.83 kB

Total Files

15

Last publish

Collaborators

  • you21979