@layerzerolabs/function-pointer
Advanced tools
@@ -14,9 +14,7 @@ WARN Issue while reading "/home/runner/work/monorepo-internal/monorepo-internal/.npmrc". Failed to replace env in config: ${NPM_TOKEN} | ||
| [34mESM[39m Build start | ||
| Generated an empty chunk: "index". | ||
| Generated an empty chunk: "index". | ||
| [32mCJS[39m [1mdist/index.cjs [22m[32m84.00 B[39m | ||
| [32mCJS[39m [1mdist/index.cjs.map [22m[32m90.00 B[39m | ||
| [32mCJS[39m ⚡️ Build success in 77ms | ||
| [32mESM[39m [1mdist/index.js [22m[32m68.00 B[39m | ||
| [32mESM[39m [1mdist/index.js.map [22m[32m89.00 B[39m | ||
| [32mCJS[39m [1mdist/index.cjs [22m[32m704.00 B[39m | ||
| [32mCJS[39m [1mdist/index.cjs.map [22m[32m2.90 KB[39m | ||
| [32mCJS[39m ⚡️ Build success in 79ms | ||
| [32mESM[39m [1mdist/index.js [22m[32m623.00 B[39m | ||
| [32mESM[39m [1mdist/index.js.map [22m[32m2.90 KB[39m | ||
| [32mESM[39m ⚡️ Build success in 79ms |
@@ -5,5 +5,5 @@ | ||
| (node:54811) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1771045407926 is not specified and it doesn't parse as CommonJS. | ||
| (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. | ||
| 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) |
+19
-0
| 'use strict'; | ||
| var __defProp = Object.defineProperty; | ||
| var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
| var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({ | ||
| ...pointer, | ||
| args: [ | ||
| ...pointer.args, | ||
| ...args | ||
| ] | ||
| }), "curryFunctionPointer"); | ||
| var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({ | ||
| ...pointer, | ||
| args: [ | ||
| ...pointer.args, | ||
| ...args | ||
| ] | ||
| }), "curryDimensionlessFunctionPointer"); | ||
| exports.curryDimensionlessFunctionPointer = curryDimensionlessFunctionPointer; | ||
| exports.curryFunctionPointer = curryFunctionPointer; | ||
| //# sourceMappingURL=index.cjs.map | ||
| //# sourceMappingURL=index.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs","sourcesContent":[]} | ||
| {"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"]} |
+12
-5
@@ -0,1 +1,3 @@ | ||
| import type { SubtractTuple } from '@layerzerolabs/typescript-utils'; | ||
| import { type TuplePrefixUnion } from '@layerzerolabs/typescript-utils'; | ||
| declare const fpSym: unique symbol; | ||
@@ -6,18 +8,23 @@ declare const dimSym: unique symbol; | ||
| */ | ||
| export type FunctionPointer<_Activity extends (...args: any[]) => Promise<any> = any> = { | ||
| export type FunctionPointer<Input extends any[] = any[], Output extends Promise<any> = Promise<any>> = { | ||
| factoryName: string; | ||
| dimKey: string; | ||
| methodName: string; | ||
| args: any[]; | ||
| } & { | ||
| [fpSym]: _Activity; | ||
| [fpSym]: (...args: Input) => Output; | ||
| }; | ||
| export type DimensionlessFunctionPointer<_Activity extends (...args: any[]) => Promise<any> = any, Dim = any> = { | ||
| export type DimensionlessFunctionPointer<Input extends any[] = any[], Output extends Promise<any> = Promise<any>, Dim = any> = { | ||
| factoryName: string; | ||
| methodName: string; | ||
| args: any[]; | ||
| } & { | ||
| [fpSym]: _Activity; | ||
| [fpSym]: (...args: Input) => Output; | ||
| [dimSym]: Dim; | ||
| }; | ||
| export type UnderlyingMethodOfFunctionPointer<Pointer extends FunctionPointer> = Pointer extends FunctionPointer<infer M> ? M : never; | ||
| 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 {}; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,eAAoB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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"} |
+17
-0
@@ -0,3 +1,20 @@ | ||
| var __defProp = Object.defineProperty; | ||
| var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
| var curryFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({ | ||
| ...pointer, | ||
| args: [ | ||
| ...pointer.args, | ||
| ...args | ||
| ] | ||
| }), "curryFunctionPointer"); | ||
| var curryDimensionlessFunctionPointer = /* @__PURE__ */ __name((pointer) => (args) => ({ | ||
| ...pointer, | ||
| args: [ | ||
| ...pointer.args, | ||
| ...args | ||
| ] | ||
| }), "curryDimensionlessFunctionPointer"); | ||
| export { curryDimensionlessFunctionPointer, curryFunctionPointer }; | ||
| //# sourceMappingURL=index.js.map | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]} | ||
| {"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"]} |
+6
-3
| { | ||
| "name": "@layerzerolabs/function-pointer", | ||
| "version": "0.2.29", | ||
| "version": "0.2.30", | ||
| "private": false, | ||
@@ -16,7 +16,10 @@ "license": "MIT", | ||
| "types": "./dist/index.d.ts", | ||
| "dependencies": { | ||
| "@layerzerolabs/typescript-utils": "0.2.30" | ||
| }, | ||
| "devDependencies": { | ||
| "tsup": "^8.4.0", | ||
| "vitest": "^3.2.3", | ||
| "@layerzerolabs/tsup-configuration": "0.2.29", | ||
| "@layerzerolabs/typescript-configuration": "0.2.29" | ||
| "@layerzerolabs/typescript-configuration": "0.2.30", | ||
| "@layerzerolabs/tsup-configuration": "0.2.30" | ||
| }, | ||
@@ -23,0 +26,0 @@ "publishConfig": { |
+50
-6
@@ -0,1 +1,4 @@ | ||
| import type { SubtractTuple } from '@layerzerolabs/typescript-utils'; | ||
| import { type TuplePrefixUnion } from '@layerzerolabs/typescript-utils'; | ||
| const fpSym = Symbol('_fp_tag'); | ||
@@ -7,12 +10,19 @@ const dimSym = Symbol('_dim_tag'); | ||
| */ | ||
| export type FunctionPointer<_Activity extends (...args: any[]) => Promise<any> = any> = { | ||
| 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[]; | ||
| } & { | ||
| [fpSym]: _Activity; | ||
| // we do it this way to preserve contravariance of the input type | ||
| [fpSym]: (...args: Input) => Output; | ||
| }; | ||
| export type DimensionlessFunctionPointer< | ||
| _Activity extends (...args: any[]) => Promise<any> = any, | ||
| Input extends any[] = any[], | ||
| Output extends Promise<any> = Promise<any>, | ||
| Dim = any, | ||
@@ -22,8 +32,42 @@ > = { | ||
| methodName: string; | ||
| args: any[]; | ||
| } & { | ||
| [fpSym]: _Activity; | ||
| [fpSym]: (...args: Input) => Output; | ||
| [dimSym]: Dim; | ||
| }; | ||
| export type UnderlyingMethodOfFunctionPointer<Pointer extends FunctionPointer> = | ||
| Pointer extends FunctionPointer<infer M> ? M : never; | ||
| 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> | ||
| >; |
17887
152.93%158
113.51%1
Infinity%+ Added