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.