1 | # Async Agent
|
2 |
|
3 | > A javascript library of async functions
|
4 | >
|
5 | > [![npm][npm]][npm-url]
|
6 | [![build][build]][build-url]
|
7 | [![coverage][coverage]][coverage-url]
|
8 | [![deps][deps]][deps-url]
|
9 | [![size][size]][size-url]
|
10 | [![vulnerabilities][vulnerabilities]][vulnerabilities-url]
|
11 | [![license][license]][license-url]
|
12 |
|
13 | <br><a name="Installation"></a>
|
14 |
|
15 | ## Installation
|
16 | ```
|
17 | npm install async-agent
|
18 | ```
|
19 | _Requires Babel 7.2+_
|
20 |
|
21 |
|
22 | <br>
|
23 |
|
24 | ## Functions
|
25 |
|
26 | <dl>
|
27 | <dt><a href="docs/clear.md">clear(id)</a></dt>
|
28 | <dd><p>Clears a defer or delay callback.</p>
|
29 | </dd>
|
30 | <dt><a href="docs/debounce.md">debounce(callback, [duration], [options])</a> ⇒ <code>function</code></dt>
|
31 | <dd><p>Returns a new debounced function that waits to call the callback until <code>duration</code> ms have passed since the last time it was called.</p>
|
32 | </dd>
|
33 | <dt><a href="docs/defer.md">defer(callback)</a> ⇒ <code>Number</code></dt>
|
34 | <dd><p>Defers the calling of a callback until the current stack is complete.</p>
|
35 | </dd>
|
36 | <dt><a href="docs/delay.md">delay(callback, [duration])</a> ⇒ <code>Number</code></dt>
|
37 | <dd><p>Delays the calling of a callback for a given amount of time.</p>
|
38 | </dd>
|
39 | <dt><a href="docs/throttle.md">throttle(callback, [duration], [options])</a> ⇒ <code>function</code></dt>
|
40 | <dd><p>Returns a new throttled function that waits to call the callback until <code>duration</code> ms have passed. Any calls to it during that time will do nothing.</p>
|
41 | </dd>
|
42 | <dt><a href="docs/wait.md">wait([duration])</a> ⇒ <code>Promise</code></dt>
|
43 | <dd><p>Delays the resolving of a new Promise for a given amount of time. Provides the same functionality as defer and delay, but with promises. Also serves as a wrapper for a Promise if a callback is provided.</p>
|
44 | </dd>
|
45 | <dt><a href="docs/rejectAfterBy.md">rejectAfterBy(duration, callback)</a> ⇒ <code>function</code></dt>
|
46 | <dd><p>Returns a function that returns a Promise that rejects with the results of a callback after a delay.</p>
|
47 | </dd>
|
48 | <dt><a href="docs/rejectAfterWith.md">rejectAfterWith([duration], [args])</a> ⇒ <code>function</code></dt>
|
49 | <dd><p>Returns a function that returns a Promise that rejects with provided args after a delay.</p>
|
50 | </dd>
|
51 | <dt><a href="docs/rejectBy.md">rejectBy([callback])</a> ⇒ <code>function</code></dt>
|
52 | <dd><p>Returns a function that returns a Promise that rejects with the results of a callback.</p>
|
53 | </dd>
|
54 | <dt><a href="docs/resolveWith.md">resolveWith([args])</a> ⇒ <code>function</code></dt>
|
55 | <dd><p>Returns a function that returns a Promise that rejects with provided args.</p>
|
56 | </dd>
|
57 | <dt><a href="docs/resolveAfterBy.md">resolveAfterBy(duration, callback)</a> ⇒ <code>function</code></dt>
|
58 | <dd><p>Returns a function that returns a Promise that resolves with the results of a callback after a delay.</p>
|
59 | </dd>
|
60 | <dt><a href="docs/resolveAfterWith.md">resolveAfterWith([duration], [args])</a> ⇒ <code>function</code></dt>
|
61 | <dd><p>Returns a function that returns a Promise that resolves with provided args after a delay.</p>
|
62 | </dd>
|
63 | <dt><a href="docs/resolveBy.md">resolveBy([callback])</a> ⇒ <code>function</code></dt>
|
64 | <dd><p>Returns a function that returns a Promise that resolves with the results of a callback.</p>
|
65 | </dd>
|
66 | <dt><a href="docs/resolveWith.md">resolveWith([args])</a> ⇒ <code>function</code></dt>
|
67 | <dd><p>Returns a function that returns a Promise that resolves with provided args.</p>
|
68 | </dd>
|
69 | <dt><a href="docs/waitBy.md">waitBy(callback)</a> ⇒ <code>function</code></dt>
|
70 | <dd><p>Returns a function that returns a Promise that calls a callback.</p>
|
71 | </dd>
|
72 | <dt><a href="docs/forRange.md">forRange(first, last, callback)</a> ⇒ <code>Promise</code></dt>
|
73 | <dd><p>Calls an async callback for a range of numbers.</p>
|
74 | </dd>
|
75 | </dl>
|
76 |
|
77 | [npm]: https://img.shields.io/npm/v/async-agent.svg
|
78 | [npm-url]: https://npmjs.com/package/async-agent
|
79 | [build]: https://travis-ci.org/DarrenPaulWright/async-agent.svg?branch=master
|
80 | [build-url]: https://travis-ci.org/DarrenPaulWright/async-agent
|
81 | [coverage]: https://coveralls.io/repos/github/DarrenPaulWright/async-agent/badge.svg?branch=master
|
82 | [coverage-url]: https://coveralls.io/github/DarrenPaulWright/async-agent?branch=master
|
83 | [deps]: https://david-dm.org/darrenpaulwright/async-agent.svg
|
84 | [deps-url]: https://david-dm.org/darrenpaulwright/async-agent
|
85 | [size]: https://packagephobia.now.sh/badge?p=async-agent
|
86 | [size-url]: https://packagephobia.now.sh/result?p=async-agent
|
87 | [vulnerabilities]: https://snyk.io/test/github/DarrenPaulWright/async-agent/badge.svg?targetFile=package.json
|
88 | [vulnerabilities-url]: https://snyk.io/test/github/DarrenPaulWright/async-agent?targetFile=package.json
|
89 | [license]: https://img.shields.io/github/license/DarrenPaulWright/async-agent.svg
|
90 | [license-url]: https://npmjs.com/package/async-agent/LICENSE.md
|