@layerzerolabs/function-pointer 0.2.100 → 0.2.102
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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ export type DimensionlessFunctionPointer<Fn extends (...args: any[]) => Promise<
|
|
|
21
21
|
export type FunctionPointerUnderlying<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Pointer extends FunctionPointer<infer Fn> ? Fn : Pointer extends DimensionlessFunctionPointer<infer Fn> ? Fn : never;
|
|
22
22
|
export type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Parameters<FunctionPointerUnderlying<Pointer>>;
|
|
23
23
|
export type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = ReturnType<FunctionPointerUnderlying<Pointer>>;
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
24
|
+
export declare const partiallyApplyFunctionPointer: <const Pointer extends FunctionPointer>(pointer: Pointer) => <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(...args: Args) => FunctionPointer<(...args: SubtractTuple<FunctionPointerInput<Pointer>, Args>) => FunctionPointerOutput<Pointer>>;
|
|
25
|
+
export declare const partiallyApplyDimensionlessFunctionPointer: <const Pointer extends DimensionlessFunctionPointer>(pointer: Pointer) => <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(...args: Args) => DimensionlessFunctionPointer<(...args: SubtractTuple<FunctionPointerInput<Pointer>, Args>) => FunctionPointerOutput<Pointer>>;
|
|
26
26
|
export declare const isFunctionPointer: (o: any) => o is FunctionPointer;
|
|
27
27
|
export type DeepFunctionPointers<Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>> = {
|
|
28
28
|
[key: string]: DeepFunctionPointers<Fn> | F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|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
var
|
|
3
|
+
var partiallyApplyFunctionPointer = /* @__PURE__ */ __name((pointer) => (...args) => ({
|
|
4
4
|
...pointer,
|
|
5
5
|
args: [
|
|
6
6
|
...pointer.args,
|
|
7
7
|
...args
|
|
8
8
|
]
|
|
9
|
-
}), "
|
|
10
|
-
var
|
|
9
|
+
}), "partiallyApplyFunctionPointer");
|
|
10
|
+
var partiallyApplyDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (...args) => ({
|
|
11
11
|
...pointer,
|
|
12
12
|
args: [
|
|
13
13
|
...pointer.args,
|
|
14
14
|
...args
|
|
15
15
|
]
|
|
16
|
-
}), "
|
|
16
|
+
}), "partiallyApplyDimensionlessFunctionPointer");
|
|
17
17
|
var isFunctionPointer = /* @__PURE__ */ __name((o) => o.args && o.dimKey && o.factoryName && o.methodName, "isFunctionPointer");
|
|
18
18
|
var deeplyResolveDeepFunctionPointers = /* @__PURE__ */ __name(async (deepFunctionPointers, resolveFunctionPointer) => Object.fromEntries(await Promise.all(Object.entries(deepFunctionPointers).map(async ([k, v]) => {
|
|
19
19
|
if (v === null) {
|
|
@@ -34,6 +34,6 @@ var deeplyResolveDeepFunctionPointers = /* @__PURE__ */ __name(async (deepFuncti
|
|
|
34
34
|
];
|
|
35
35
|
}))), "deeplyResolveDeepFunctionPointers");
|
|
36
36
|
|
|
37
|
-
export {
|
|
37
|
+
export { deeplyResolveDeepFunctionPointers, isFunctionPointer, partiallyApplyDimensionlessFunctionPointer, partiallyApplyFunctionPointer };
|
|
38
38
|
//# sourceMappingURL=index.js.map
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["partiallyApplyFunctionPointer","pointer","args","partiallyApplyDimensionlessFunctionPointer","isFunctionPointer","o","dimKey","factoryName","methodName","deeplyResolveDeepFunctionPointers","deepFunctionPointers","resolveFunctionPointer","Object","fromEntries","Promise","all","entries","map","k","v"],"mappings":";;AAgDO,IAAMA,6BAAAA,mBACT,MAAA,CAAA,CAAwCC,OAAAA,KACxC,CAAA,GAAwEC,IAAAA,MACnE;EACG,GAAGD,OAAAA;EACHC,IAAAA,EAAM;OAAID,OAAAA,CAAQC,IAAAA;AAASA,IAAAA,GAAAA;;AAC/B,CAAA,CAAA,EALJ,+BAAA;AAWG,IAAMC,0CAAAA,mBACT,MAAA,CAAA,CAAqDF,OAAAA,KACrD,CAAA,GAAwEC,IAAAA,MACnE;EACG,GAAGD,OAAAA;EACHC,IAAAA,EAAM;OAAID,OAAAA,CAAQC,IAAAA;AAASA,IAAAA,GAAAA;;AAC/B,CAAA,CAAA,EALJ,4CAAA;AAWG,IAAME,iBAAAA,mBAAoB,MAAA,CAAA,CAACC,CAAAA,KAC9BA,CAAAA,CAAEH,IAAAA,IAAQG,EAAEC,MAAAA,IAAUD,CAAAA,CAAEE,WAAAA,IAAeF,CAAAA,CAAEG,UAAAA,EADZ,mBAAA;AAmB1B,IAAMC,oDAAoC,MAAA,CAAA,OAG7CC,oBAAAA,EACAC,2BAEAC,MAAAA,CAAOC,WAAAA,CACH,MAAMC,OAAAA,CAAQC,GAAAA,CACVH,MAAAA,CAAOI,OAAAA,CAAQN,oBAAAA,CAAAA,CAAsBO,GAAAA,CAAI,OAAO,CAACC,CAAAA,EAAGC,CAAAA,CAAAA,KAAE;AAClD,EAAA,IAAIA,MAAM,IAAA,EAAM;AACZ,IAAA,OAAO;AAACD,MAAAA,CAAAA;AAAGC,MAAAA;;AACf,EAAA;AAEA,EAAA,IAAIf,iBAAAA,CAAkBe,CAAAA,CAAAA,EAAI;AACtB,IAAA,OAAO;AAACD,MAAAA,CAAAA;AAAG,MAAA,MAAMP,uBAAuBQ,CAAAA;;AAC5C,EAAA;AAEA,EAAA,OAAO;AACHD,IAAAA,CAAAA;IACA,MAAMT,iCAAAA,CACFU,GACAR,sBAAAA;;AAGZ,CAAA,CAAA,CAAA,CAAA,EAxBqC,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\nexport type FunctionPointer<\n Fn extends (...args: any[]) => Promise<any> = (...args: 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 // AND to brand the pointer\n [fpSym]: Fn;\n};\n\nexport type DimensionlessFunctionPointer<\n Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>,\n Dim = any,\n> = {\n factoryName: string;\n methodName: string;\n args: any[];\n} & {\n [fpSym]: Fn;\n [dimSym]: Dim;\n};\n\nexport type FunctionPointerUnderlying<\n Pointer extends FunctionPointer | DimensionlessFunctionPointer,\n> =\n Pointer extends FunctionPointer<infer Fn>\n ? Fn\n : Pointer extends DimensionlessFunctionPointer<infer Fn>\n ? Fn\n : never;\n\nexport type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =\n Parameters<FunctionPointerUnderlying<Pointer>>;\n\nexport type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =\n ReturnType<FunctionPointerUnderlying<Pointer>>;\n\n// Does not and cannot preserve generic functions\nexport const partiallyApplyFunctionPointer =\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 (\n ...args: SubtractTuple<FunctionPointerInput<Pointer>, Args>\n ) => FunctionPointerOutput<Pointer>\n >;\n\nexport const partiallyApplyDimensionlessFunctionPointer =\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 (\n ...args: SubtractTuple<FunctionPointerInput<Pointer>, Args>\n ) => FunctionPointerOutput<Pointer>\n >;\n\nexport const isFunctionPointer = (o: any): o is FunctionPointer =>\n o.args && o.dimKey && o.factoryName && o.methodName;\n\nexport type DeepFunctionPointers<\n Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>,\n> = {\n [key: string]: DeepFunctionPointers<Fn> | FunctionPointer<Fn> | null;\n};\n\nexport type DeeplyResolvedDeepFunctionPointers<Pointers extends DeepFunctionPointers> = {\n [K in keyof Pointers]: Pointers[K] extends FunctionPointer\n ? Awaited<FunctionPointerOutput<Pointers[K]>>\n : Pointers[K] extends DeepFunctionPointers\n ? DeeplyResolvedDeepFunctionPointers<Pointers[K]>\n : Pointers[K] extends null\n ? null\n : never;\n};\n\nexport const deeplyResolveDeepFunctionPointers = async <\n Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>,\n>(\n deepFunctionPointers: DeepFunctionPointers<Fn>,\n resolveFunctionPointer: (pointer: FunctionPointer<Fn>) => ReturnType<Fn>,\n) =>\n Object.fromEntries(\n await Promise.all(\n Object.entries(deepFunctionPointers).map(async ([k, v]): Promise<any> => {\n if (v === null) {\n return [k, v];\n }\n // this is kind of hacky but if this case occurs we have bigger problems\n if (isFunctionPointer(v)) {\n return [k, await resolveFunctionPointer(v as FunctionPointer<Fn>)];\n }\n\n return [\n k,\n await deeplyResolveDeepFunctionPointers(\n v as DeepFunctionPointers<Fn>,\n resolveFunctionPointer,\n ),\n ];\n }),\n ),\n ) as Promise<DeeplyResolvedDeepFunctionPointers<DeepFunctionPointers<Fn>>>;\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.102",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"dist/**/*"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@layerzerolabs/typescript-utils": "0.2.
|
|
19
|
+
"@layerzerolabs/typescript-utils": "0.2.102"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"tsup": "^8.4.0",
|
|
23
23
|
"vitest": "^3.2.3",
|
|
24
|
-
"@layerzerolabs/
|
|
25
|
-
"@layerzerolabs/
|
|
24
|
+
"@layerzerolabs/typescript-configuration": "0.2.102",
|
|
25
|
+
"@layerzerolabs/tsup-configuration": "0.2.102"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public",
|