1.0.0 • Published 5 years ago

@jam3/wait v1.0.0

Weekly downloads
29
License
MIT
Repository
github
Last release
5 years ago

wait

Minimalistic library that promisified setTimeout.

Installation

npm install @jam3/wait

Usage

Basic usage

const wait = require('@jam3/wait');

wait(1500).then(callback);

Async/Await example

const wait = require('@jam3/wait');

async function animate() {
  await wait(0); // Wait for JS to dequeue this call and do some rending in the meanwhile
  console.log('Waited at least 0 milliseconds');
}

Promises example

const wait = require('@jam3/wait');

async function runProcess() {
  ...
  await Promise.all([setTimer, other]);
  ...
}

async setTimer() {
  return await wait(1000);
}

Alternatives

If you want a more complete library, with a couple extra bytes, checkout delay