Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 2 KB

delay.md

File metadata and controls

53 lines (42 loc) · 2 KB

Async Agent

A javascript library of async functions

npm build coverage deps size vulnerabilities license


delay(callback, [duration]) ⇒ number

Delays the calling of a callback for a given amount of time.

Returns: number - An id that can be used to clear the callback before it gets called.

Param Type Default Description
callback function The function to delay execution of.
[duration] number 0 Time in milliseconds.

Example

import { delay } from 'async-agent';

delay(() => {
    console.log('2');
}, 1000);

console.log('1');

// => 1
// (after 1000ms) => 2