@layerzerolabs/typescript-utils 0.0.29 → 0.0.31

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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,cAAA,EAAA","file":"index.js","sourcesContent":["export * from './advancedRecord';\nexport * from './branded';\nexport * from './constructor';\nexport * from './deep';\nexport * from './disallowedAny';\nexport * from './lastOf';\nexport * from './merge';\nexport * from './methodOf';\nexport * from './removeNever';\nexport * from './strings';\nexport * from './tuples';\nexport * from './valueOf';\nexport * from './viem';\nexport * from './withRequired';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,cAAA,EAAA","file":"index.js","sourcesContent":["export * from './advancedRecord';\nexport * from './branded';\nexport * from './constructor';\nexport * from './deep';\nexport * from './disallowedAny';\nexport * from './identity';\nexport * from './lastOf';\nexport * from './merge';\nexport * from './methodOf';\nexport * from './removeNever';\nexport * from './strings';\nexport * from './tuples';\nexport * from './valueOf';\nexport * from './viem';\nexport * from './withRequired';\n"]}
package/dist/tuples.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- require('./LSUYSAW6.cjs');
3
+ require('./CEQAD5SY.cjs');
4
4
  require('./U7VZULNU.cjs');
5
5
 
6
6
  //# sourceMappingURL=tuples.cjs.map
package/dist/tuples.d.ts CHANGED
@@ -2,4 +2,7 @@ import type { BrandedError } from './branded';
2
2
  export type IsComplete<T extends readonly (string | number | symbol)[], K extends string | number | symbol> = Exclude<K, T[number]> extends never ? true : false;
3
3
  export type TryGetDuplicate<T extends readonly (string | number | symbol)[], Seen extends (string | number | symbol)[] = []> = T extends [infer Head, ...infer Tail] ? Head extends Seen[number] ? Head : Head extends string | number | symbol ? Tail extends readonly (string | number | symbol)[] ? TryGetDuplicate<Tail, [...Seen, Head]> : false : false : false;
4
4
  export type AssertUniqueCompleteSet<T extends readonly (string | number | symbol)[], AllKeys extends string | number | symbol> = IsComplete<T, AllKeys> extends false ? BrandedError<`Missing key: ${Exclude<AllKeys extends Symbol ? 'ERR' : AllKeys, T[number]>}`> : TryGetDuplicate<T> extends false ? T : BrandedError<`Duplicate key found: ${TryGetDuplicate<T>}`>;
5
+ type BuildTupleHelper<Element, Length extends number, Rest extends Element[]> = Rest['length'] extends Length ? readonly [...Rest] : BuildTupleHelper<Element, Length, [Element, ...Rest]>;
6
+ export type BuildTuple<Element, Length extends number> = number extends Length ? readonly Element[] : BuildTupleHelper<Element, Length, []>;
7
+ export {};
5
8
  //# sourceMappingURL=tuples.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tuples.d.ts","sourceRoot":"","sources":["../src/tuples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,MAAM,MAAM,UAAU,CAClB,CAAC,SAAS,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,EAC/C,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,IAClC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AAEvD,MAAM,MAAM,eAAe,CACvB,CAAC,SAAS,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,EAC/C,IAAI,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,IAC9C,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GACnC,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,GACrB,IAAI,GACJ,IAAI,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GACnC,IAAI,SAAS,SAAS,CAAC,MAAM,GAAG,MAAM,G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G2D5.js';
2
2
  import './4RNWLMHM.js';
3
3
  //# sourceMappingURL=tuples.js.map
4
4
  //# sourceMappingURL=tuples.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/typescript-utils",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,8 +16,8 @@
16
16
  "devDependencies": {
17
17
  "tsup": "^8.4.0",
18
18
  "vitest": "^3.2.3",
19
- "@layerzerolabs/tsup-configuration": "0.0.29",
20
- "@layerzerolabs/typescript-configuration": "0.0.29"
19
+ "@layerzerolabs/tsup-configuration": "0.0.31",
20
+ "@layerzerolabs/typescript-configuration": "0.0.31"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "restricted",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "scripts": {
27
27
  "build": "tsup",
28
- "checkdeps": "pnpm --filter @layerzerolabs/depcheck run depcheck validate --missing-dependencies --only $npm_package_name",
28
+ "checkdeps": "pnpm --filter @layerzerolabs/depcheck run depcheck validate --catalog --missing-dependencies --only $npm_package_name",
29
29
  "clean": "rm -rf ./node_modules .turbo ./dist",
30
30
  "dev": "tsup --watch",
31
31
  "lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)"
@@ -0,0 +1,2 @@
1
+ // Wraps types and property access with 1-arity which enables creating interfaces
2
+ export type Identity<T> = T;
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export * from './branded';
3
3
  export * from './constructor';
4
4
  export * from './deep';
5
5
  export * from './disallowedAny';
6
+ export * from './identity';
6
7
  export * from './lastOf';
7
8
  export * from './merge';
8
9
  export * from './methodOf';
package/src/tuples.ts CHANGED
@@ -30,3 +30,16 @@ export type AssertUniqueCompleteSet<
30
30
  : TryGetDuplicate<T> extends false
31
31
  ? T
32
32
  : BrandedError<`Duplicate key found: ${TryGetDuplicate<T>}`>;
33
+
34
+ type BuildTupleHelper<
35
+ Element,
36
+ Length extends number,
37
+ Rest extends Element[],
38
+ > = Rest['length'] extends Length
39
+ ? readonly [...Rest] // Terminate with readonly array (aka tuple)
40
+ : BuildTupleHelper<Element, Length, [Element, ...Rest]>;
41
+
42
+ export type BuildTuple<Element, Length extends number> = number extends Length
43
+ ? // Because `Length extends number` and `number extends Length`, then `Length` is not a specific finite number.
44
+ readonly Element[] // It's not fixed length.
45
+ : BuildTupleHelper<Element, Length, []>; // Otherwise it is a fixed length tuple.