longbill / pwait

Promise based setTimeout with nothing to do

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install

npm i --save pwait

Usage

async/await:

const wait = require('pwait');
async function doSomething() {
	//...
	await wait(1000); //wait 1000ms and do nothing
	//...
}

Promise:

const wait = require('pwait');
wait(1000).then(()=>{
	console.log('after 1s');
}).then(()=>wait(1000)).then(()=>{
	console.log('another 1s');
});

About

Promise based setTimeout with nothing to do

License:MIT License


Languages

Language:JavaScript 100.0%