@andytan07/delay-es
v1.0.1
Published
Simple delay based on ES6/ES7 Promise and async/await
Downloads
13
Readme
delay-es
A simple stupid delay function based on ES6/ES7 Promise or async/await that tends to replace setTimeout
without any extra functions.
To install,
> npm install --save @andytan07/delay-es
Usage:
const delay = require("@andytan07/delay-es");
// With ES6 Promise
console.log("Before delay");
delay(1000).then(() => console.log("Delayed 1000ms"));
// With ES7 async/await
(async () => {
console.log("Before delay");
await delay(1000);
console.log("Delayed 1000ms");
})();
API
As simple as:
delay(milliseconds)
Create a promise that resolves after specified milliseconds
License
MIT © Andy Tan