Module @knicola/delay - v0.1.0

@knicola/delay

Delay code execution for a specified amount of milliseconds. This is an isomorphic variation of require('timers/promises').setTimeout(1000).

Install

Using npm:

$ npm install @knicola/delay

Using yarn:

$ yarn add @knicola/delay

Usage

import { delay, AbortError } from '@knicola/delay'

const ac = new AbortController()

// abort after 3 seconds
setTimeout(() => ac.abort(), 3000)

try {
await delay(10e3, ac.signal)
// work, work ..
} catch (err) {
if (err instanceof AbortError) {
// operation aborted ..
}
}

License

This project is open-sourced software licensed under the MIT license.

Index

Classes

Functions

Generated using TypeDoc