@xstd/async-function 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +3 -2
- package/src/async-function.d.ts +3 -3
- package/src/async-function.js +1 -2
- package/src/async-function.js.map +1 -1
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -3
- package/src/index.js.map +1 -1
- package/src/types/methods/map-arguments/built-in/map-one-argument.d.ts +0 -16
- package/src/types/methods/map-arguments/built-in/map-one-argument.js +0 -18
- package/src/types/methods/map-arguments/built-in/map-one-argument.js.map +0 -1
- package/src/types/methods/map-arguments/built-in/set-arguments.d.ts +0 -14
- package/src/types/methods/map-arguments/built-in/set-arguments.js +0 -16
- package/src/types/methods/map-arguments/built-in/set-arguments.js.map +0 -1
- package/src/types/methods/map-arguments/map-function-arguments.d.ts +0 -3
- package/src/types/methods/map-arguments/map-function-arguments.js +0 -2
- package/src/types/methods/map-arguments/map-function-arguments.js.map +0 -1
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ Applies a transformation function to the current instance and returns the result
|
|
|
175
175
|
|
|
176
176
|
```ts
|
|
177
177
|
mapArguments<GNewArguments extends readonly unknown[]>(
|
|
178
|
-
mapFnc: MapFunctionArguments<
|
|
178
|
+
mapFnc: MapFunctionArguments<GNewArguments, GArguments>,
|
|
179
179
|
): AsyncFunction<GNewArguments, GReturn>
|
|
180
180
|
```
|
|
181
181
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xstd/async-function",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Universal API around async functions",
|
|
6
6
|
"keywords": [],
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@xstd/abortable": "^1.2.3"
|
|
22
|
+
"@xstd/abortable": "^1.2.3",
|
|
23
|
+
"@xstd/map-function": "^1.0.0"
|
|
23
24
|
}
|
|
24
25
|
}
|
package/src/async-function.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { MapFunctionArguments } from '@xstd/map-function';
|
|
1
2
|
import { type AsyncFunctionLike } from './types/async-function-like.ts';
|
|
2
|
-
import { type MapFunctionArguments } from './types/methods/map-arguments/map-function-arguments.ts';
|
|
3
3
|
import { type ShareConcurentCallsOptions } from './types/methods/share-concurent-calls/share-concurent-calls-options.js';
|
|
4
4
|
import { type AsyncFunctionThenOnFulfilledFunction } from './types/methods/then/async-function.then.on-fulfilled-function.ts';
|
|
5
5
|
import { type AsyncFunctionThenOnRejectedFunction } from './types/methods/then/async-function.then.on-rejected-function.ts';
|
|
@@ -89,10 +89,10 @@ export declare class AsyncFunction<GArguments extends readonly unknown[], GRetur
|
|
|
89
89
|
* Maps and transforms the arguments of the current async function using the provided mapping function.
|
|
90
90
|
*
|
|
91
91
|
* @template GNewArguments The tuple type of the new arguments to be provided to the async function.
|
|
92
|
-
* @param {MapFunctionArguments<
|
|
92
|
+
* @param {MapFunctionArguments<GNewArguments, GArguments>} mapFnc A function that receives the arguments for the new async function and transforms them into arguments for the current async function.
|
|
93
93
|
* @return {AsyncFunction<GNewArguments, GReturn>} A new async function instance that uses the specified mapping function to map its arguments.
|
|
94
94
|
*/
|
|
95
|
-
mapArguments<GNewArguments extends readonly unknown[]>(mapFnc: MapFunctionArguments<
|
|
95
|
+
mapArguments<GNewArguments extends readonly unknown[]>(mapFnc: MapFunctionArguments<GNewArguments, GArguments>): AsyncFunction<GNewArguments, GReturn>;
|
|
96
96
|
/**
|
|
97
97
|
* Creates a new async function with the same behaviour as this one (neither a fulfilment nor a rejection handler provided).
|
|
98
98
|
*
|
package/src/async-function.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { abortify } from '@xstd/abortable';
|
|
2
2
|
import {} from './types/async-function-like.js';
|
|
3
3
|
import {} from './types/call-async-function.js';
|
|
4
|
-
import {} from './types/methods/map-arguments/map-function-arguments.js';
|
|
5
4
|
import {} from './types/methods/share-concurent-calls/share-concurent-calls-options.js';
|
|
6
5
|
import {} from './types/methods/then/async-function.then.on-fulfilled-function.js';
|
|
7
6
|
import {} from './types/methods/then/async-function.then.on-rejected-function.js';
|
|
@@ -122,7 +121,7 @@ export class AsyncFunction {
|
|
|
122
121
|
* Maps and transforms the arguments of the current async function using the provided mapping function.
|
|
123
122
|
*
|
|
124
123
|
* @template GNewArguments The tuple type of the new arguments to be provided to the async function.
|
|
125
|
-
* @param {MapFunctionArguments<
|
|
124
|
+
* @param {MapFunctionArguments<GNewArguments, GArguments>} mapFnc A function that receives the arguments for the new async function and transforms them into arguments for the current async function.
|
|
126
125
|
* @return {AsyncFunction<GNewArguments, GReturn>} A new async function instance that uses the specified mapping function to map its arguments.
|
|
127
126
|
*/
|
|
128
127
|
mapArguments(mapFnc) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-function.js","sourceRoot":"","sources":["../../src/async-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"async-function.js","sourceRoot":"","sources":["../../src/async-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAA0B,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAA0B,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAmC,MAAM,wEAAwE,CAAC;AACzH,OAAO,EAA6C,MAAM,mEAAmE,CAAC;AAC9H,OAAO,EAA4C,MAAM,kEAAkE,CAAC;AAC5H,OAAO,EAAE,iDAAiD,EAAE,MAAM,mFAAmF,CAAC;AACtJ,OAAO,EAAE,gDAAgD,EAAE,MAAM,kFAAkF,CAAC;AACpJ,OAAO,EAAuC,MAAM,gEAAgE,CAA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B;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,EAClB,YAAY,GAC2B;QAOvC,MAAM,GAAG,GAAuB,IAAI,GAAG,EAAiB,CAAC;QAEzD,OAAO,IAAI,aAAa,CACtB,KAAK,EAAE,MAAmB,EAAE,GAAG,IAAgB,EAAoB,EAAE;YACnE,MAAM,CAAC,cAAc,EAAE,CAAC;YAExB,MAAM,GAAG,GAAW,YAAY,CAAC,IAAI,CAAC,CAAC;YAEvC,IAAI,KAAK,GAAsB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAE5C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,UAAU,GAAoB,IAAI,eAAe,EAAE,CAAC;gBAC1D,KAAK,GAAG;oBACN,UAAU;oBACV,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;oBAC9C,SAAS,EAAE,CAAC;iBACb,CAAC;gBACF,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACtB,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,CAAC;YAED,IAAI,CAAC;gBACH,OAAO,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YACnD,CAAC;oBAAS,CAAC;gBACT,KAAK,CAAC,SAAS,EAAE,CAAC;gBAElB,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;oBAC1B,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;oBACzB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
|
package/src/index.d.ts
CHANGED
|
@@ -6,6 +6,3 @@ export * from './types/methods/transform/transform-async-function-function.ts';
|
|
|
6
6
|
export * from './types/methods/then/async-function.then.on-fulfilled-function.ts';
|
|
7
7
|
export * from './types/methods/then/async-function.then.on-rejected-function.ts';
|
|
8
8
|
export * from './types/methods/share-concurent-calls/share-concurent-calls-options.ts';
|
|
9
|
-
export * from './types/methods/map-arguments/map-function-arguments.ts';
|
|
10
|
-
export * from './types/methods/map-arguments/built-in/map-one-argument.ts';
|
|
11
|
-
export * from './types/methods/map-arguments/built-in/set-arguments.ts';
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,4 @@ export * from './types/methods/transform/transform-async-function-function.js';
|
|
|
6
6
|
export * from './types/methods/then/async-function.then.on-fulfilled-function.js';
|
|
7
7
|
export * from './types/methods/then/async-function.then.on-rejected-function.js';
|
|
8
8
|
export * from './types/methods/share-concurent-calls/share-concurent-calls-options.js';
|
|
9
|
-
export * from './types/methods/map-arguments/map-function-arguments.js';
|
|
10
|
-
export * from './types/methods/map-arguments/built-in/map-one-argument.js';
|
|
11
|
-
export * from './types/methods/map-arguments/built-in/set-arguments.js';
|
|
12
9
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8FAA8F,CAAC;AAC7G,cAAc,gEAAgE,CAAC;AAC/E,cAAc,mEAAmE,CAAC;AAClF,cAAc,kEAAkE,CAAC;AACjF,cAAc,wEAAwE,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8FAA8F,CAAC;AAC7G,cAAc,gEAAgE,CAAC;AAC/E,cAAc,mEAAmE,CAAC;AAClF,cAAc,kEAAkE,CAAC;AACjF,cAAc,wEAAwE,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { MapFunctionArguments } from '../map-function-arguments.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Used to map the first argument of a Flow to another one.
|
|
4
|
-
*
|
|
5
|
-
* @template GIn - The type of the source argument.
|
|
6
|
-
* @template GOut - The type of the destination argument.
|
|
7
|
-
* @param {(value: GIn) => GOut} mapFnc - The function to map the source argument to the destination one.
|
|
8
|
-
* @returns {MapFunctionArguments<[GOut], [GIn]>} - A function that maps one argument to another one.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const value = await fnc.mapArguments(mapOneArgument(Number)).call(signal, '10');
|
|
14
|
-
* ``
|
|
15
|
-
*/
|
|
16
|
-
export declare function mapOneArgument<GIn, GOut>(mapFnc: (value: GIn) => GOut): MapFunctionArguments<[GOut], [GIn]>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Used to map the first argument of a Flow to another one.
|
|
3
|
-
*
|
|
4
|
-
* @template GIn - The type of the source argument.
|
|
5
|
-
* @template GOut - The type of the destination argument.
|
|
6
|
-
* @param {(value: GIn) => GOut} mapFnc - The function to map the source argument to the destination one.
|
|
7
|
-
* @returns {MapFunctionArguments<[GOut], [GIn]>} - A function that maps one argument to another one.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* const value = await fnc.mapArguments(mapOneArgument(Number)).call(signal, '10');
|
|
13
|
-
* ``
|
|
14
|
-
*/
|
|
15
|
-
export function mapOneArgument(mapFnc) {
|
|
16
|
-
return (value) => [mapFnc(value)];
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=map-one-argument.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map-one-argument.js","sourceRoot":"","sources":["../../../../../../src/types/methods/map-arguments/built-in/map-one-argument.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAY,MAA4B;IACpE,OAAO,CAAC,KAAU,EAAU,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { MapFunctionArguments } from '../map-function-arguments.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Used to set the arguments of an AsyncFunction.
|
|
4
|
-
*
|
|
5
|
-
* @param args - The arguments to set.
|
|
6
|
-
* @returns {MapFunctionArguments<GArguments, []>} - A function that maps no arguments to a list of predefined ones.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* const value = await fnc.mapArguments(setArguments(10)).call(signal);
|
|
12
|
-
* ``
|
|
13
|
-
*/
|
|
14
|
-
export declare function setArguments<GArguments extends readonly unknown[]>(...args: GArguments): MapFunctionArguments<GArguments, []>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Used to set the arguments of an AsyncFunction.
|
|
3
|
-
*
|
|
4
|
-
* @param args - The arguments to set.
|
|
5
|
-
* @returns {MapFunctionArguments<GArguments, []>} - A function that maps no arguments to a list of predefined ones.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const value = await fnc.mapArguments(setArguments(10)).call(signal);
|
|
11
|
-
* ``
|
|
12
|
-
*/
|
|
13
|
-
export function setArguments(...args) {
|
|
14
|
-
return () => args;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=set-arguments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set-arguments.js","sourceRoot":"","sources":["../../../../../../src/types/methods/map-arguments/built-in/set-arguments.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAG,IAAgB;IAEnB,OAAO,GAAe,EAAE,CAAC,IAAI,CAAC;AAChC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map-function-arguments.js","sourceRoot":"","sources":["../../../../../src/types/methods/map-arguments/map-function-arguments.ts"],"names":[],"mappings":""}
|