1
- A collection of ways for transforming async functions .<br >
1
+ An [ async function ] is a function that delivers its [ result asynchronously ] (through [ Promise ] ) .<br >
2
2
📦 [ Node.js] ( https://www.npmjs.com/package/extra-async-function ) ,
3
3
🌐 [ Web] ( https://www.npmjs.com/package/extra-async-function.web ) ,
4
4
📜 [ Files] ( https://unpkg.com/extra-async-function/ ) ,
5
5
📰 [ JSDoc] ( https://nodef.github.io/extra-async-function/ ) ,
6
6
📘 [ Wiki] ( https://github.com/nodef/extra-async-function/wiki/ ) .
7
7
8
- An [ async function] is a function that delivers its [ result asynchronously]
9
- (through [ Promise] ). This package is an * variant* of [ extra-function] , and
10
- includes methods for transforming * async functions* . The ** result** of an async
11
- function can be manipulated with [ negate] . If a * pure* async function is
12
- expensive, its results can ** cached** with [ memoize] . ** Parameters** of a
13
- function can be manipulated with [ reverse] , [ spread] , [ unspread] . [ reverse]
14
- flips the order of parameters, [ spread] spreads the first array parameter of a
15
- function, and [ unspread] combines all parameters into the first parameter
16
- (array). If you want some ** functional behavior** , [ compose] , [ composeRight] ,
17
- [ curry] , and [ curryRight] can be used. [ composeRight] is also known as
18
- [ pipe-forward operator] or [ function chaining] . If you are unfamiliar, [ Haskell]
19
- is a great purely functional language, and there is great [ haskell beginner
20
- guide] to learn from.
8
+ This package is an * variant* of [ extra-function] , and includes methods for
9
+ transforming * async functions* . The ** result** of an async function can be
10
+ manipulated with [ negate] . If a * pure* async function is expensive, its results
11
+ can ** cached** with [ memoize] . ** Parameters** of a function can be manipulated
12
+ with [ reverse] , [ spread] , [ unspread] . [ reverse] flips the order of parameters,
13
+ [ spread] spreads the first array parameter of a function, and [ unspread]
14
+ combines all parameters into the first parameter (array). If you want some
15
+ ** functional behavior** , [ compose] , [ composeRight] , [ curry] , and [ curryRight]
16
+ can be used. [ composeRight] is also known as [ pipe-forward operator] or
17
+ [ function chaining] . If you are unfamiliar, [ Haskell] is a great purely
18
+ functional language, and there is great [ haskell beginner guide] to learn from.
21
19
22
20
To control invocation ** time** of a function, use [ delay] . A function can be
23
21
** rate controlled** with [ debounce] , [ debounceEarly] , [ throttle] ,
@@ -35,9 +33,9 @@ In addition, [is], [name], and [length] obtain metadata (about) information on
35
33
an async function. To attach a ` this ` to a function, use [ bind] . A few generic
36
34
async functions are also included: [ ARGUMENTS] , [ NOOP] , [ IDENTITY] , [ COMPARE] .
37
35
38
- This package is available in both * Node.js* and * Web* formats. The web format is
39
- exposed as ` extra_async_function ` standalone variable and can be loaded from
40
- [ jsDelivr CDN] .
36
+ This package is available in * Node.js* and * Web* formats. To use it on the web,
37
+ simply use the ` extra_async_function ` global variable after loading with a ` <script> `
38
+ tag from the [ jsDelivr CDN] .
41
39
42
40
[ async function ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
43
41
[ result asynchronously ] : https://exploringjs.com/impatient-js/ch_async-functions.html#async-constructs
@@ -56,21 +54,21 @@ exposed as `extra_async_function` standalone variable and can be loaded from
56
54
57
55
58
56
``` javascript
59
- const asyncFunction = require (' extra-async-function' );
60
- // import * as asyncFunction from "extra-async-function";
61
- // import * as asyncFunction from "https://unpkg.com/extra-async-function/index.mjs"; (deno)
57
+ const xasyncfn = require (' extra-async-function' );
58
+ // import * as xasyncfn from "extra-async-function";
59
+ // import * as xasyncfn from "https://unpkg.com/extra-async-function/index.mjs"; (deno)
62
60
63
61
// 1. Basic tests.
64
62
async function example1 () {
65
- var a = asyncFunction .composeRight (async x => x* x, async x => x+ 2 );
63
+ var a = xasyncfn .composeRight (async x => x* x, async x => x+ 2 );
66
64
await a (10 );
67
65
// → 102
68
66
69
- var a = asyncFunction .curry (async (x , y ) => x+ y);
67
+ var a = xasyncfn .curry (async (x , y ) => x+ y);
70
68
await a (2 )(3 );
71
69
// → 7
72
70
73
- var a = asyncFunction .unspread (async (... xs ) => Math .max (... xs));
71
+ var a = xasyncfn .unspread (async (... xs ) => Math .max (... xs));
74
72
await a ([2 , 3 , 1 ]);
75
73
// → 1.25
76
74
}
0 commit comments