Skip to content

classtype/app.wait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Что это?

App.wait — это npm-пакет с помощью которого вы можете создавать искусственные задержки через await.

Установка

$ npm i app.wait

Пример

const wait = require('app.wait');

(async () => {
    let t = new Date().getTime();
    
    await wait(1000);
    console.log(new Date().getTime() - t);
    
    await wait(1000);
    console.log(new Date().getTime() - t);
    
    await wait(1000);
    console.log(new Date().getTime() - t);
    
    await wait(1000);
    console.log(new Date().getTime() - t);
    
    //=> 1004
    //=> 2012
    //=> 3014
    //=> 4015
})();

Исходный код

module.exports = (ms) => {
    return new Promise((resolve) => {
        setTimeout(resolve, ms);
    });
};

Как мы видим это просто promise обернутый в setTimeout.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published