@layerzerolabs/function-pointer 0.2.29 → 0.2.30
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/.turbo/turbo-build.log +5 -7
- package/.turbo/turbo-lint.log +1 -1
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/src/index.ts +50 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
13
|
[34mESM[39m Build start
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[32mCJS[39m
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[32mESM[39m [1mdist/index.js [22m[32m68.00 B[39m
|
|
20
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m89.00 B[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m704.00 B[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m2.90 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 79ms
|
|
17
|
+
[32mESM[39m [1mdist/index.js [22m[32m623.00 B[39m
|
|
18
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m2.90 KB[39m
|
|
21
19
|
[32mESM[39m ⚡️ Build success in 79ms
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
> @layerzerolabs/function-pointer@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/framework/definitions/function-pointer
|
|
3
3
|
> eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
|
|
4
4
|
|
|
5
|
-
(node:
|
|
5
|
+
(node:55223) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1771449390046 is not specified and it doesn't parse as CommonJS.
|
|
6
6
|
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
7
|
To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
|
|
8
8
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
|
|
6
|
+
...pointer,
|
|
7
|
+
args: [
|
|
8
|
+
...pointer.args,
|
|
9
|
+
...args
|
|
10
|
+
]
|
|
11
|
+
}), "curryFunctionPointer");
|
|
12
|
+
var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
|
|
13
|
+
...pointer,
|
|
14
|
+
args: [
|
|
15
|
+
...pointer.args,
|
|
16
|
+
...args
|
|
17
|
+
]
|
|
18
|
+
}), "curryDimensionlessFunctionPointer");
|
|
19
|
+
|
|
20
|
+
exports.curryDimensionlessFunctionPointer = curryDimensionlessFunctionPointer;
|
|
21
|
+
exports.curryFunctionPointer = curryFunctionPointer;
|
|
3
22
|
//# sourceMappingURL=index.cjs.map
|
|
4
23
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["curryFunctionPointer","pointer","args","curryDimensionlessFunctionPointer"],"mappings":";;;;AAkDO,IAAMA,oBAAAA,mBACT,MAAA,CAAA,CAAwCC,OAAAA,KACxC,CAAqEC,IAAAA,MAChE;EACG,GAAGD,OAAAA;EACHC,IAAAA,EAAM;OAAID,OAAAA,CAAQC,IAAAA;AAASA,IAAAA,GAAAA;;AAC/B,CAAA,CAAA,EALJ,sBAAA;AAUG,IAAMC,iCAAAA,mBACT,MAAA,CAAA,CAAqDF,OAAAA,KACrD,CAAqEC,IAAAA,MAChE;EACG,GAAGD,OAAAA;EACHC,IAAAA,EAAM;OAAID,OAAAA,CAAQC,IAAAA;AAASA,IAAAA,GAAAA;;AAC/B,CAAA,CAAA,EALJ,mCAAA","file":"index.cjs","sourcesContent":["import type { SubtractTuple } from '@layerzerolabs/typescript-utils';\nimport { type TuplePrefixUnion } from '@layerzerolabs/typescript-utils';\n\nconst fpSym = Symbol('_fp_tag');\nconst dimSym = Symbol('_dim_tag');\n\n/**\n * <!-- anchor:FunctionPointer -->\n */\nexport type FunctionPointer<\n Input extends any[] = any[],\n Output extends Promise<any> = Promise<any>,\n> = {\n factoryName: string;\n dimKey: string;\n methodName: string;\n // an improper subset of the arguments expected by the method this points to\n args: any[];\n} & {\n // we do it this way to preserve contravariance of the input type\n [fpSym]: (...args: Input) => Output;\n};\n\nexport type DimensionlessFunctionPointer<\n Input extends any[] = any[],\n Output extends Promise<any> = Promise<any>,\n Dim = any,\n> = {\n factoryName: string;\n methodName: string;\n args: any[];\n} & {\n [fpSym]: (...args: Input) => Output;\n [dimSym]: Dim;\n};\n\nexport type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =\n Pointer extends FunctionPointer<infer M>\n ? M\n : Pointer extends DimensionlessFunctionPointer<infer M>\n ? M\n : never;\n\nexport type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =\n Pointer extends FunctionPointer<any, infer A>\n ? A\n : Pointer extends DimensionlessFunctionPointer<any, infer A>\n ? A\n : never;\n\nexport const curryFunctionPointer =\n <const Pointer extends FunctionPointer>(pointer: Pointer) =>\n <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>\n ({\n ...pointer,\n args: [...pointer.args, ...args],\n }) as unknown as FunctionPointer<\n SubtractTuple<FunctionPointerInput<Pointer>, Args>,\n FunctionPointerOutput<Pointer>\n >;\n\nexport const curryDimensionlessFunctionPointer =\n <const Pointer extends DimensionlessFunctionPointer>(pointer: Pointer) =>\n <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>\n ({\n ...pointer,\n args: [...pointer.args, ...args],\n }) as unknown as DimensionlessFunctionPointer<\n SubtractTuple<FunctionPointerInput<Pointer>, Args>,\n FunctionPointerOutput<Pointer>\n >;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
+
import type { SubtractTuple } from '@layerzerolabs/typescript-utils';
|
|
2
|
+
import { type TuplePrefixUnion } from '@layerzerolabs/typescript-utils';
|
|
1
3
|
declare const fpSym: unique symbol;
|
|
2
4
|
declare const dimSym: unique symbol;
|
|
3
5
|
/**
|
|
4
6
|
* <!-- anchor:FunctionPointer -->
|
|
5
7
|
*/
|
|
6
|
-
export type FunctionPointer<
|
|
8
|
+
export type FunctionPointer<Input extends any[] = any[], Output extends Promise<any> = Promise<any>> = {
|
|
7
9
|
factoryName: string;
|
|
8
10
|
dimKey: string;
|
|
9
11
|
methodName: string;
|
|
12
|
+
args: any[];
|
|
10
13
|
} & {
|
|
11
|
-
[fpSym]:
|
|
14
|
+
[fpSym]: (...args: Input) => Output;
|
|
12
15
|
};
|
|
13
|
-
export type DimensionlessFunctionPointer<
|
|
16
|
+
export type DimensionlessFunctionPointer<Input extends any[] = any[], Output extends Promise<any> = Promise<any>, Dim = any> = {
|
|
14
17
|
factoryName: string;
|
|
15
18
|
methodName: string;
|
|
19
|
+
args: any[];
|
|
16
20
|
} & {
|
|
17
|
-
[fpSym]:
|
|
21
|
+
[fpSym]: (...args: Input) => Output;
|
|
18
22
|
[dimSym]: Dim;
|
|
19
23
|
};
|
|
20
|
-
export type
|
|
24
|
+
export type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Pointer extends FunctionPointer<infer M> ? M : Pointer extends DimensionlessFunctionPointer<infer M> ? M : never;
|
|
25
|
+
export type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Pointer extends FunctionPointer<any, infer A> ? A : Pointer extends DimensionlessFunctionPointer<any, infer A> ? A : never;
|
|
26
|
+
export declare const curryFunctionPointer: <const Pointer extends FunctionPointer>(pointer: Pointer) => <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) => FunctionPointer<SubtractTuple<FunctionPointerInput<Pointer>, Args>, FunctionPointerOutput<Pointer>>;
|
|
27
|
+
export declare const curryDimensionlessFunctionPointer: <const Pointer extends DimensionlessFunctionPointer>(pointer: Pointer) => <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) => DimensionlessFunctionPointer<SubtractTuple<FunctionPointerInput<Pointer>, Args>, FunctionPointerOutput<Pointer>>;
|
|
21
28
|
export {};
|
|
22
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,eAAoB,CAAC;AAChC,QAAA,MAAM,MAAM,eAAqB,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,QAAA,MAAM,KAAK,eAAoB,CAAC;AAChC,QAAA,MAAM,MAAM,eAAqB,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,eAAe,CACvB,KAAK,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAC3B,MAAM,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAC1C;IACA,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,EAAE,GAAG,EAAE,CAAC;CACf,GAAG;IAEA,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,4BAA4B,CACpC,KAAK,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAC3B,MAAM,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAC1C,GAAG,GAAG,GAAG,IACT;IACA,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;CACf,GAAG;IACA,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;IACpC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,eAAe,GAAG,4BAA4B,IAC3F,OAAO,SAAS,eAAe,CAAC,MAAM,CAAC,CAAC,GAClC,CAAC,GACD,OAAO,SAAS,4BAA4B,CAAC,MAAM,CAAC,CAAC,GACnD,CAAC,GACD,KAAK,CAAC;AAElB,MAAM,MAAM,qBAAqB,CAAC,OAAO,SAAS,eAAe,GAAG,4BAA4B,IAC5F,OAAO,SAAS,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GACvC,CAAC,GACD,OAAO,SAAS,4BAA4B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GACxD,CAAC,GACD,KAAK,CAAC;AAElB,eAAO,MAAM,oBAAoB,GAC5B,KAAK,CAAC,OAAO,SAAS,eAAe,EAAE,SAAS,OAAO,MACvD,KAAK,CAAC,IAAI,SAAS,gBAAgB,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,IAAI,KAI1D,eAAe,CAC5B,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAClD,qBAAqB,CAAC,OAAO,CAAC,CACjC,CAAC;AAEV,eAAO,MAAM,iCAAiC,GACzC,KAAK,CAAC,OAAO,SAAS,4BAA4B,EAAE,SAAS,OAAO,MACpE,KAAK,CAAC,IAAI,SAAS,gBAAgB,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,IAAI,KAI1D,4BAA4B,CACzC,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAClD,qBAAqB,CAAC,OAAO,CAAC,CACjC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
|
|
4
|
+
...pointer,
|
|
5
|
+
args: [
|
|
6
|
+
...pointer.args,
|
|
7
|
+
...args
|
|
8
|
+
]
|
|
9
|
+
}), "curryFunctionPointer");
|
|
10
|
+
var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
|
|
11
|
+
...pointer,
|
|
12
|
+
args: [
|
|
13
|
+
...pointer.args,
|
|
14
|
+
...args
|
|
15
|
+
]
|
|
16
|
+
}), "curryDimensionlessFunctionPointer");
|
|
1
17
|
|
|
18
|
+
export { curryDimensionlessFunctionPointer, curryFunctionPointer };
|
|
2
19
|
//# sourceMappingURL=index.js.map
|
|
3
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["curryFunctionPointer","pointer","args","curryDimensionlessFunctionPointer"],"mappings":";;AAkDO,IAAMA,oBAAAA,mBACT,MAAA,CAAA,CAAwCC,OAAAA,KACxC,CAAqEC,IAAAA,MAChE;EACG,GAAGD,OAAAA;EACHC,IAAAA,EAAM;OAAID,OAAAA,CAAQC,IAAAA;AAASA,IAAAA,GAAAA;;AAC/B,CAAA,CAAA,EALJ,sBAAA;AAUG,IAAMC,iCAAAA,mBACT,MAAA,CAAA,CAAqDF,OAAAA,KACrD,CAAqEC,IAAAA,MAChE;EACG,GAAGD,OAAAA;EACHC,IAAAA,EAAM;OAAID,OAAAA,CAAQC,IAAAA;AAASA,IAAAA,GAAAA;;AAC/B,CAAA,CAAA,EALJ,mCAAA","file":"index.js","sourcesContent":["import type { SubtractTuple } from '@layerzerolabs/typescript-utils';\nimport { type TuplePrefixUnion } from '@layerzerolabs/typescript-utils';\n\nconst fpSym = Symbol('_fp_tag');\nconst dimSym = Symbol('_dim_tag');\n\n/**\n * <!-- anchor:FunctionPointer -->\n */\nexport type FunctionPointer<\n Input extends any[] = any[],\n Output extends Promise<any> = Promise<any>,\n> = {\n factoryName: string;\n dimKey: string;\n methodName: string;\n // an improper subset of the arguments expected by the method this points to\n args: any[];\n} & {\n // we do it this way to preserve contravariance of the input type\n [fpSym]: (...args: Input) => Output;\n};\n\nexport type DimensionlessFunctionPointer<\n Input extends any[] = any[],\n Output extends Promise<any> = Promise<any>,\n Dim = any,\n> = {\n factoryName: string;\n methodName: string;\n args: any[];\n} & {\n [fpSym]: (...args: Input) => Output;\n [dimSym]: Dim;\n};\n\nexport type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =\n Pointer extends FunctionPointer<infer M>\n ? M\n : Pointer extends DimensionlessFunctionPointer<infer M>\n ? M\n : never;\n\nexport type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =\n Pointer extends FunctionPointer<any, infer A>\n ? A\n : Pointer extends DimensionlessFunctionPointer<any, infer A>\n ? A\n : never;\n\nexport const curryFunctionPointer =\n <const Pointer extends FunctionPointer>(pointer: Pointer) =>\n <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>\n ({\n ...pointer,\n args: [...pointer.args, ...args],\n }) as unknown as FunctionPointer<\n SubtractTuple<FunctionPointerInput<Pointer>, Args>,\n FunctionPointerOutput<Pointer>\n >;\n\nexport const curryDimensionlessFunctionPointer =\n <const Pointer extends DimensionlessFunctionPointer>(pointer: Pointer) =>\n <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>\n ({\n ...pointer,\n args: [...pointer.args, ...args],\n }) as unknown as DimensionlessFunctionPointer<\n SubtractTuple<FunctionPointerInput<Pointer>, Args>,\n FunctionPointerOutput<Pointer>\n >;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/function-pointer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.30",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
"main": "./dist/index.cjs",
|
|
14
14
|
"module": "./dist/index.js",
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@layerzerolabs/typescript-utils": "0.2.30"
|
|
18
|
+
},
|
|
16
19
|
"devDependencies": {
|
|
17
20
|
"tsup": "^8.4.0",
|
|
18
21
|
"vitest": "^3.2.3",
|
|
19
|
-
"@layerzerolabs/
|
|
20
|
-
"@layerzerolabs/
|
|
22
|
+
"@layerzerolabs/typescript-configuration": "0.2.30",
|
|
23
|
+
"@layerzerolabs/tsup-configuration": "0.2.30"
|
|
21
24
|
},
|
|
22
25
|
"publishConfig": {
|
|
23
26
|
"access": "restricted",
|
package/src/index.ts
CHANGED
|
@@ -1,27 +1,71 @@
|
|
|
1
|
+
import type { SubtractTuple } from '@layerzerolabs/typescript-utils';
|
|
2
|
+
import { type TuplePrefixUnion } from '@layerzerolabs/typescript-utils';
|
|
3
|
+
|
|
1
4
|
const fpSym = Symbol('_fp_tag');
|
|
2
5
|
const dimSym = Symbol('_dim_tag');
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* <!-- anchor:FunctionPointer -->
|
|
6
9
|
*/
|
|
7
|
-
export type FunctionPointer<
|
|
10
|
+
export type FunctionPointer<
|
|
11
|
+
Input extends any[] = any[],
|
|
12
|
+
Output extends Promise<any> = Promise<any>,
|
|
13
|
+
> = {
|
|
8
14
|
factoryName: string;
|
|
9
15
|
dimKey: string;
|
|
10
16
|
methodName: string;
|
|
17
|
+
// an improper subset of the arguments expected by the method this points to
|
|
18
|
+
args: any[];
|
|
11
19
|
} & {
|
|
12
|
-
|
|
20
|
+
// we do it this way to preserve contravariance of the input type
|
|
21
|
+
[fpSym]: (...args: Input) => Output;
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
export type DimensionlessFunctionPointer<
|
|
16
|
-
|
|
25
|
+
Input extends any[] = any[],
|
|
26
|
+
Output extends Promise<any> = Promise<any>,
|
|
17
27
|
Dim = any,
|
|
18
28
|
> = {
|
|
19
29
|
factoryName: string;
|
|
20
30
|
methodName: string;
|
|
31
|
+
args: any[];
|
|
21
32
|
} & {
|
|
22
|
-
[fpSym]:
|
|
33
|
+
[fpSym]: (...args: Input) => Output;
|
|
23
34
|
[dimSym]: Dim;
|
|
24
35
|
};
|
|
25
36
|
|
|
26
|
-
export type
|
|
27
|
-
Pointer extends FunctionPointer<infer M>
|
|
37
|
+
export type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =
|
|
38
|
+
Pointer extends FunctionPointer<infer M>
|
|
39
|
+
? M
|
|
40
|
+
: Pointer extends DimensionlessFunctionPointer<infer M>
|
|
41
|
+
? M
|
|
42
|
+
: never;
|
|
43
|
+
|
|
44
|
+
export type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =
|
|
45
|
+
Pointer extends FunctionPointer<any, infer A>
|
|
46
|
+
? A
|
|
47
|
+
: Pointer extends DimensionlessFunctionPointer<any, infer A>
|
|
48
|
+
? A
|
|
49
|
+
: never;
|
|
50
|
+
|
|
51
|
+
export const curryFunctionPointer =
|
|
52
|
+
<const Pointer extends FunctionPointer>(pointer: Pointer) =>
|
|
53
|
+
<const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>
|
|
54
|
+
({
|
|
55
|
+
...pointer,
|
|
56
|
+
args: [...pointer.args, ...args],
|
|
57
|
+
}) as unknown as FunctionPointer<
|
|
58
|
+
SubtractTuple<FunctionPointerInput<Pointer>, Args>,
|
|
59
|
+
FunctionPointerOutput<Pointer>
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
export const curryDimensionlessFunctionPointer =
|
|
63
|
+
<const Pointer extends DimensionlessFunctionPointer>(pointer: Pointer) =>
|
|
64
|
+
<const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>
|
|
65
|
+
({
|
|
66
|
+
...pointer,
|
|
67
|
+
args: [...pointer.args, ...args],
|
|
68
|
+
}) as unknown as DimensionlessFunctionPointer<
|
|
69
|
+
SubtractTuple<FunctionPointerInput<Pointer>, Args>,
|
|
70
|
+
FunctionPointerOutput<Pointer>
|
|
71
|
+
>;
|