Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@layerzerolabs/function-pointer

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@layerzerolabs/function-pointer - npm Package Compare versions

Comparing version
0.2.68
to
0.2.69
+23
-2
dist/index.cjs

@@ -5,3 +5,3 @@ 'use strict';

var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (...args) => ({
...pointer,

@@ -13,3 +13,3 @@ args: [

}), "curryFunctionPointer");
var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (...args) => ({
...pointer,

@@ -21,6 +21,27 @@ args: [

}), "curryDimensionlessFunctionPointer");
var isFunctionPointer = /* @__PURE__ */ __name((o) => o.args && o.dimKey && o.factoryName && o.methodName, "isFunctionPointer");
var deeplyResolveDeepFunctionPointers = /* @__PURE__ */ __name(async (deepFunctionPointers, resolveFunctionPointer) => Object.fromEntries(await Promise.all(Object.entries(deepFunctionPointers).map(async ([k, v]) => {
if (v === null) {
return [
k,
v
];
}
if (isFunctionPointer(v)) {
return [
k,
await resolveFunctionPointer(v)
];
}
return [
k,
await deeplyResolveDeepFunctionPointers(v, resolveFunctionPointer)
];
}))), "deeplyResolveDeepFunctionPointers");
exports.curryDimensionlessFunctionPointer = curryDimensionlessFunctionPointer;
exports.curryFunctionPointer = curryFunctionPointer;
exports.deeplyResolveDeepFunctionPointers = deeplyResolveDeepFunctionPointers;
exports.isFunctionPointer = isFunctionPointer;
//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map
+1
-1

@@ -1,1 +0,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"]}
{"version":3,"sources":["../src/index.ts"],"names":["curryFunctionPointer","pointer","args","curryDimensionlessFunctionPointer","isFunctionPointer","o","dimKey","factoryName","methodName","deeplyResolveDeepFunctionPointers","deepFunctionPointers","resolveFunctionPointer","Object","fromEntries","Promise","all","entries","map","k","v"],"mappings":";;;;AAgDO,IAAMA,oBAAAA,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,sBAAA;AAWG,IAAMC,iCAAAA,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,mCAAA;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.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\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 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 (\n ...args: 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 (\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"]}

@@ -5,6 +5,3 @@ import type { SubtractTuple } from '@layerzerolabs/typescript-utils';

declare const dimSym: unique symbol;
/**
* <!-- anchor:FunctionPointer -->
*/
export type FunctionPointer<Input extends any[] = any[], Output extends Promise<any> = Promise<any>> = {
export type FunctionPointer<Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>> = {
factoryName: string;

@@ -15,5 +12,5 @@ dimKey: string;

} & {
[fpSym]: (...args: Input) => Output;
[fpSym]: Fn;
};
export type DimensionlessFunctionPointer<Input extends any[] = any[], Output extends Promise<any> = Promise<any>, Dim = any> = {
export type DimensionlessFunctionPointer<Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>, Dim = any> = {
factoryName: string;

@@ -23,10 +20,19 @@ methodName: string;

} & {
[fpSym]: (...args: Input) => Output;
[fpSym]: Fn;
[dimSym]: Dim;
};
export type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Pointer extends FunctionPointer<infer M> ? M : Pointer extends DimensionlessFunctionPointer<infer M> ? M : never;
export type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Pointer extends FunctionPointer<any, infer A> ? A : Pointer extends DimensionlessFunctionPointer<any, infer A> ? A : never;
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>>;
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>>;
export type FunctionPointerUnderlying<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Pointer extends FunctionPointer<infer Fn> ? Fn : Pointer extends DimensionlessFunctionPointer<infer Fn> ? Fn : never;
export type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = Parameters<FunctionPointerUnderlying<Pointer>>;
export type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> = ReturnType<FunctionPointerUnderlying<Pointer>>;
export declare const curryFunctionPointer: <const Pointer extends FunctionPointer>(pointer: Pointer) => <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(...args: Args) => FunctionPointer<(...args: SubtractTuple<FunctionPointerInput<Pointer>, Args>) => FunctionPointerOutput<Pointer>>;
export declare const curryDimensionlessFunctionPointer: <const Pointer extends DimensionlessFunctionPointer>(pointer: Pointer) => <const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(...args: Args) => DimensionlessFunctionPointer<(...args: SubtractTuple<FunctionPointerInput<Pointer>, Args>) => FunctionPointerOutput<Pointer>>;
export declare const isFunctionPointer: (o: any) => o is FunctionPointer;
export type DeepFunctionPointers<Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>> = {
[key: string]: DeepFunctionPointers<Fn> | FunctionPointer<Fn> | null;
};
export type DeeplyResolvedDeepFunctionPointers<Pointers extends DeepFunctionPointers> = {
[K in keyof Pointers]: Pointers[K] extends FunctionPointer ? Awaited<FunctionPointerOutput<Pointers[K]>> : Pointers[K] extends DeepFunctionPointers ? DeeplyResolvedDeepFunctionPointers<Pointers[K]> : Pointers[K] extends null ? null : never;
};
export declare const deeplyResolveDeepFunctionPointers: <Fn extends (...args: any[]) => Promise<any> = (...args: any[]) => Promise<any>>(deepFunctionPointers: DeepFunctionPointers<Fn>, resolveFunctionPointer: (pointer: FunctionPointer<Fn>) => ReturnType<Fn>) => Promise<DeeplyResolvedDeepFunctionPointers<DeepFunctionPointers<Fn>>>;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -1,1 +0,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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B,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;CACxE,CAAC;AAEF,MAAM,MAAM,kCAAkC,CAAC,QAAQ,SAAS,oBAAoB,IAAI;KACnF,CAAC,IAAI,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,eAAe,GACpD,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3C,QAAQ,CAAC,CAAC,CAAC,SAAS,oBAAoB,GACtC,kCAAkC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAC/C,QAAQ,CAAC,CAAC,CAAC,SAAS,IAAI,GACtB,IAAI,GACJ,KAAK;CAClB,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC1C,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAE9E,sBAAsB,oBAAoB,CAAC,EAAE,CAAC,EAC9C,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC,KAAK,UAAU,CAAC,EAAE,CAAC,0EAsBE,CAAC"}
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (...args) => ({
...pointer,

@@ -10,3 +10,3 @@ args: [

}), "curryFunctionPointer");
var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({
var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (...args) => ({
...pointer,

@@ -18,5 +18,24 @@ args: [

}), "curryDimensionlessFunctionPointer");
var isFunctionPointer = /* @__PURE__ */ __name((o) => o.args && o.dimKey && o.factoryName && o.methodName, "isFunctionPointer");
var deeplyResolveDeepFunctionPointers = /* @__PURE__ */ __name(async (deepFunctionPointers, resolveFunctionPointer) => Object.fromEntries(await Promise.all(Object.entries(deepFunctionPointers).map(async ([k, v]) => {
if (v === null) {
return [
k,
v
];
}
if (isFunctionPointer(v)) {
return [
k,
await resolveFunctionPointer(v)
];
}
return [
k,
await deeplyResolveDeepFunctionPointers(v, resolveFunctionPointer)
];
}))), "deeplyResolveDeepFunctionPointers");
export { curryDimensionlessFunctionPointer, curryFunctionPointer };
export { curryDimensionlessFunctionPointer, curryFunctionPointer, deeplyResolveDeepFunctionPointers, isFunctionPointer };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

@@ -1,1 +0,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"]}
{"version":3,"sources":["../src/index.ts"],"names":["curryFunctionPointer","pointer","args","curryDimensionlessFunctionPointer","isFunctionPointer","o","dimKey","factoryName","methodName","deeplyResolveDeepFunctionPointers","deepFunctionPointers","resolveFunctionPointer","Object","fromEntries","Promise","all","entries","map","k","v"],"mappings":";;AAgDO,IAAMA,oBAAAA,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,sBAAA;AAWG,IAAMC,iCAAAA,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,mCAAA;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 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 (\n ...args: 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 (\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"]}
{
"name": "@layerzerolabs/function-pointer",
"version": "0.2.68",
"version": "0.2.69",
"private": false,

@@ -16,4 +16,7 @@ "license": "MIT",

"types": "./dist/index.d.ts",
"files": [
"dist/**/*"
],
"dependencies": {
"@layerzerolabs/typescript-utils": "0.2.68"
"@layerzerolabs/typescript-utils": "0.2.69"
},

@@ -23,4 +26,4 @@ "devDependencies": {

"vitest": "^3.2.3",
"@layerzerolabs/tsup-configuration": "0.2.68",
"@layerzerolabs/typescript-configuration": "0.2.68"
"@layerzerolabs/typescript-configuration": "0.2.69",
"@layerzerolabs/tsup-configuration": "0.2.69"
},

@@ -27,0 +30,0 @@ "publishConfig": {

 WARN  Issue while reading "/home/runner/work/monorepo-internal/monorepo-internal/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
> @layerzerolabs/function-pointer@0.0.0 build /home/runner/work/monorepo-internal/monorepo-internal/packages/framework/definitions/function-pointer
> tsup
CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v8.5.1
CLI Using tsup config: /home/runner/work/monorepo-internal/monorepo-internal/packages/framework/definitions/function-pointer/tsup.config.ts
CLI Target: ES2023
CLI Cleaning output folder
CJS Build start
ESM Build start
CJS dist/index.cjs 704.00 B
CJS dist/index.cjs.map 2.90 KB
CJS ⚡️ Build success in 101ms
ESM dist/index.js 623.00 B
ESM dist/index.js.map 2.90 KB
ESM ⚡️ Build success in 100ms
> @layerzerolabs/function-pointer@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/framework/definitions/function-pointer
> eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
(node:72533) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1775694520701 is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
(Use `node --trace-warnings ...` to show where the warning was created)
> @layerzerolabs/function-pointer@0.0.0 test /home/runner/work/monorepo-internal/monorepo-internal/packages/framework/definitions/function-pointer
> vitest --run --pass-with-no-tests --typecheck
Testing types with tsc and vue-tsc is an experimental feature.
Breaking changes might not follow SemVer, please pin Vitest's version when using it.
 RUN  v3.2.4 /home/runner/work/monorepo-internal/monorepo-internal/packages/framework/definitions/function-pointer
No test files found, exiting with code 0
include: **/*.{test,spec}.?(c|m)[jt]s?(x)
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
typecheck include: **/*.{test,spec}-d.?(c|m)[jt]s?(x)
typecheck exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
import type { SubtractTuple } from '@layerzerolabs/typescript-utils';
import { type TuplePrefixUnion } from '@layerzerolabs/typescript-utils';
const fpSym = Symbol('_fp_tag');
const dimSym = Symbol('_dim_tag');
/**
* <!-- anchor:FunctionPointer -->
*/
export type FunctionPointer<
Input extends any[] = any[],
Output extends Promise<any> = Promise<any>,
> = {
factoryName: string;
dimKey: string;
methodName: string;
// an improper subset of the arguments expected by the method this points to
args: any[];
} & {
// we do it this way to preserve contravariance of the input type
[fpSym]: (...args: Input) => Output;
};
export type DimensionlessFunctionPointer<
Input extends any[] = any[],
Output extends Promise<any> = Promise<any>,
Dim = any,
> = {
factoryName: string;
methodName: string;
args: any[];
} & {
[fpSym]: (...args: Input) => Output;
[dimSym]: Dim;
};
export type FunctionPointerInput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =
Pointer extends FunctionPointer<infer M>
? M
: Pointer extends DimensionlessFunctionPointer<infer M>
? M
: never;
export type FunctionPointerOutput<Pointer extends FunctionPointer | DimensionlessFunctionPointer> =
Pointer extends FunctionPointer<any, infer A>
? A
: Pointer extends DimensionlessFunctionPointer<any, infer A>
? A
: never;
export const curryFunctionPointer =
<const Pointer extends FunctionPointer>(pointer: Pointer) =>
<const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>
({
...pointer,
args: [...pointer.args, ...args],
}) as unknown as FunctionPointer<
SubtractTuple<FunctionPointerInput<Pointer>, Args>,
FunctionPointerOutput<Pointer>
>;
export const curryDimensionlessFunctionPointer =
<const Pointer extends DimensionlessFunctionPointer>(pointer: Pointer) =>
<const Args extends TuplePrefixUnion<FunctionPointerInput<Pointer>>>(args: Args) =>
({
...pointer,
args: [...pointer.args, ...args],
}) as unknown as DimensionlessFunctionPointer<
SubtractTuple<FunctionPointerInput<Pointer>, Args>,
FunctionPointerOutput<Pointer>
>;
{
"extends": "@layerzerolabs/typescript-configuration/tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"strictPropertyInitialization": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"jsx": "react-jsx"
},
"exclude": [
"node_modules",
"**/__mocks__/*",
"**/__tests__/*",
"**/*.spec.ts",
"**/*.test.ts",
"dist"
],
"include": ["src/**/*"]
}
import { defineConfig } from 'tsup';
import { createPackageTsupConfig } from '@layerzerolabs/tsup-configuration';
export default defineConfig(({ watch }) => ({
...createPackageTsupConfig(),
clean: !watch,
}));