A Javascript module for waiting different amounts of time.


Keywords
wait, sleep, hold, js, await, holdon, ms, s, min, hr, async-await, javascript, nodejs, npm-module, promises, typescript
License
MIT
Install
npm install holddotjs@1.1.1

Documentation

Hold.js ๐ŸšŒ๐Ÿƒ๐Ÿปโ€โ™‚๏ธ

When something feels right... Hold on to it! :) A Javascript module for waiting different amounts of time.

Getting Started

Install

npm install holddotjs

Import

const hold = require('holddotjs');

API Reference

Hold.js API makes it easy to wait for milliseconds, seconds, minutes and even hours.

async function makeBusLeave() {
    await hold.millisecs(5);    // -> ๐Ÿ˜ญ Holds for 5ms
    await hold.seconds(30);     // -> ๐Ÿ˜ž Holds for 30s
    await hold.minutes(10);     // -> ๐Ÿ˜ฆ Holds for 10min
    await hold.hours(2);        // -> ๐Ÿ˜„ Holds for 2hrs

    console.log('๐ŸšŒ๐Ÿ’จ leaving...');
}

Function Type Definitions

/**
 * @param ms The amount of milliseconds to wait.
 * @return A promise that gets resolved after a given amount of milliseconds.
 */
function millisecs(ms: number): Promise<void>;

/**
 * @param s The amount of seconds to wait.
 * @return A promise that gets resolved after a given amount of seconds.
 */
function seconds(s: number): Promise<void>;

/**
 * @param min The amount of minutes to wait.
 * @return A promise that gets resolved after a given amount of minutes.
 */
function minutes(min: number): Promise<void>;

/**
 * @param hr The amount of hours to wait.
 * @return A promise that gets resolved after a given amount of hours.
 */
function hours(hr: number): Promise<void>;

License

Hold.js is licensed under the MIT License.