waitoperationsdeprecated

A library of helper methods for pausing execution.

Usage no npm install needed!

<script type="module">
  import waitoperations from 'https://cdn.skypack.dev/waitoperations';
</script>

README

waitoperations NPM version

A library of helper methods for pausing execution

Installation

Simply do: npm install waitoperations.

What is it?

It's simply a collection of Promise-based helper methods for pausing execution such as wait().

Example

import {wait} from "waitoperations";

async function waiter () {
    await wait(1000);
    console.log("Hello World!");
}
// Prints 'Hello World!' to the console after 1000ms.

Changelog:

v0.01:

  • First release. Has the method wait().

Usage

Import it in your project like this:

import {wait, ...} from "waitoperations"; // (standard) Transpiled to ES5.
// or

import {wait, ...} from "waitoperations/native" // Transpiled to ES5, native ES-modules.
// or

import {wait, ...} from "waitoperations/typed" // Flow typings, ES-modules.

Documentation

#wait()

Waits the given amount of ms and then resolves the Promise.

Signature:

wait (time: number = 0): Promise<void>

Arguments:

  • time: number - The amount of ms to wait. defalt: 0

Returns:

Promise<void> - A promise that will resolve after the given wait time.

Throws:

  • TypeError - If the first argument is not of type 'number'.

Example

async function waiter () {
    await wait(1000);
    console.log("Hello World!");
}
// Prints 'Hello World!' to the console after 1000ms.