promises-utils.wait
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

installation

npm install promises-utils.wait

promises-utils.wait

A utility module to fire a Promise that will be resolved after the time given in the parameter.

usage

import { wait } from 'promises-utils.wait';

async function example() {
  await wait(1000);
  console.log('after 1 second');
}

/**
 * Can also use 's'(seconds), 'm'(minutes), 'h'(hours) 'd'(days)
 */
async function example2() {
  await wait(10, { timeUnit: 's' });
  console.log('after 10 seconds');
}

async function exampleRejects() {
  try {
    await wait(10, { reject: true });

    console.log('never reaches here');
  } catch (err) {
    console.log('logs this after 10 ms');
  }
}

Package Sidebar

Install

npm i promises-utils.wait

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

14 kB

Total Files

10

Last publish

Collaborators

  • jordanh