1. yoctodelay
Delay a promise a specified amount of time
yoctodelay
Package: yoctodelay
Created by: sindresorhus
Last modified: Wed, 25 May 2022 06:44:22 GMT
Version: 2.0.0
License: MIT
Downloads: 65,844
Repository: https://github.com/sindresorhus/yoctodelay

Install

npm install yoctodelay
yarn add yoctodelay

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.

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code