yoctodelay
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

yoctodelay

Delay a promise a specified amount of time

It's less than half the size of the nanodelay module.

Note: If you target Node.js 16 or later, you can use the built-in functionality instead:

import {setTimeout as delay} from 'node:timers/promises';

await delay(100);

Install

$ npm install yoctodelay

Usage

import delay from 'yoctodelay';

foo();

await delay(100);

// Executed 100 milliseconds later
bar();

API

delay(milliseconds)

Delay the promise and then resolve.

milliseconds

Type: number

The duration to delay the promise.

FAQ

What is yocto?

It's the smallest official unit prefix in the metric system. Much smaller than nano.

Is this a joke?

Partly. The nanodelay module was created only because the delay module is a tiny bit larger. Well, this module is a tiny bit smaller than the nanodelay module. Comparing size at the byte level is super silly. It doesn't matter unless the difference is more than many kilobytes. This is still a fully working module though. Go ahead and use it.

Related

  • delay - Similar to this module but with more features
  • More…

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    65
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    65
  • 1.2.0
    14,075
  • 1.1.0
    93
  • 1.0.0
    0

Package Sidebar

Install

npm i yoctodelay

Weekly Downloads

14,233

Version

2.0.0

License

MIT

Unpacked Size

3.77 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus