@layerzerolabs/typescript-utils 0.0.21 → 0.0.22
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 +59 -67
- package/dist/{LXPGE3ZL.js → EXZ6DAVW.js} +2 -2
- package/dist/EXZ6DAVW.js.map +1 -0
- package/dist/{ODTE4REV.cjs → OQCEYCFE.cjs} +2 -2
- package/dist/OQCEYCFE.cjs.map +1 -0
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/strings.cjs +1 -1
- package/dist/strings.d.ts +16 -0
- package/dist/strings.d.ts.map +1 -1
- package/dist/strings.js +1 -1
- package/dist/strings.test-d.cjs +5 -0
- package/dist/strings.test-d.cjs.map +1 -1
- package/dist/strings.test-d.js +5 -0
- package/dist/strings.test-d.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +0 -1
- package/src/strings.test-d.ts +12 -1
- package/src/strings.ts +29 -0
- package/dist/5YKETKDX.js +0 -6
- package/dist/5YKETKDX.js.map +0 -1
- package/dist/LRDSETNH.cjs +0 -8
- package/dist/LRDSETNH.cjs.map +0 -1
- package/dist/LXPGE3ZL.js.map +0 -1
- package/dist/ODTE4REV.cjs.map +0 -1
- package/dist/hexString.cjs +0 -7
- package/dist/hexString.cjs.map +0 -1
- package/dist/hexString.d.ts +0 -4
- package/dist/hexString.d.ts.map +0 -1
- package/dist/hexString.js +0 -4
- package/dist/hexString.js.map +0 -1
- package/src/hexString.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/typescript-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
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.
|
|
20
|
-
"@layerzerolabs/typescript-configuration": "0.0.
|
|
19
|
+
"@layerzerolabs/tsup-configuration": "0.0.22",
|
|
20
|
+
"@layerzerolabs/typescript-configuration": "0.0.22"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "restricted",
|
package/src/index.ts
CHANGED
package/src/strings.test-d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expectTypeOf, test } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import type { StringWithoutSuffix } from './strings';
|
|
3
|
+
import type { HexStringIsTrimmed, StringWithoutSuffix } from './strings';
|
|
4
4
|
|
|
5
5
|
test('StringWithoutSuffix', () => {
|
|
6
6
|
type A = StringWithoutSuffix<'hello', 'world'>;
|
|
@@ -19,3 +19,14 @@ test('StringWithoutSuffix', () => {
|
|
|
19
19
|
type E = StringWithoutSuffix<'hello world!', 'lo' | 'world'>;
|
|
20
20
|
expectTypeOf<E>().toBeString();
|
|
21
21
|
});
|
|
22
|
+
|
|
23
|
+
test('HexStringIsTrimmed', () => {
|
|
24
|
+
type A = HexStringIsTrimmed<'0x0'>;
|
|
25
|
+
expectTypeOf<A>().toExtend<true>();
|
|
26
|
+
|
|
27
|
+
type B = HexStringIsTrimmed<'0x00'>;
|
|
28
|
+
expectTypeOf<B>().toExtend<false>();
|
|
29
|
+
|
|
30
|
+
type C = HexStringIsTrimmed<'0x'>;
|
|
31
|
+
expectTypeOf<C>().toExtend<false>();
|
|
32
|
+
});
|
package/src/strings.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Branded } from './branded';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Guarantees that a string does not end with a suffix.
|
|
3
5
|
* You can remove multiple suffixes by using a union.
|
|
@@ -11,3 +13,30 @@ export type StringWithoutSuffix<
|
|
|
11
13
|
T extends string,
|
|
12
14
|
Suffix extends string,
|
|
13
15
|
> = T extends `${infer _}${Suffix}` ? never : T;
|
|
16
|
+
|
|
17
|
+
export type HexString = `0x${string}`;
|
|
18
|
+
|
|
19
|
+
export declare const _NormalizedHexString: unique symbol;
|
|
20
|
+
|
|
21
|
+
export type NormalizedHexString = Branded<typeof _NormalizedHexString, 'NormalizedHexString'>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Guarantees that a hex string is trimmed.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* type A = HexStringIsTrimmed<'0x0'>; // true
|
|
28
|
+
* type B = HexStringIsTrimmed<'0x00'>; // false
|
|
29
|
+
* type C = HexStringIsTrimmed<'0x'>; // false
|
|
30
|
+
* type D = HexStringIsTrimmed<'0x100'>; // true
|
|
31
|
+
*/
|
|
32
|
+
export type HexStringIsTrimmed<T extends HexString> = T extends '0x0'
|
|
33
|
+
? true
|
|
34
|
+
: T extends '0x'
|
|
35
|
+
? false
|
|
36
|
+
: T extends `0x0${string}`
|
|
37
|
+
? false
|
|
38
|
+
: true;
|
|
39
|
+
|
|
40
|
+
export declare const _DecimalString: unique symbol;
|
|
41
|
+
|
|
42
|
+
export type DecimalString = Branded<typeof _DecimalString, 'DecimalString'>;
|
package/dist/5YKETKDX.js
DELETED
package/dist/5YKETKDX.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hexString.ts"],"names":[],"mappings":";;;AAEA,cAAA,EAAA","file":"5YKETKDX.js","sourcesContent":["export type HexString = `0x${string}`;\nexport type NormalizedHexString = Symbol;\nexport type HexStringIsTrimmed<T extends HexString> = T extends '0x0'\n ? true\n : T extends `0x0${string}`\n ? false\n : true;\n"]}
|
package/dist/LRDSETNH.cjs
DELETED
package/dist/LRDSETNH.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hexString.ts"],"names":["init_cjs_shims"],"mappings":";;;;;AAEAA,2BAAA,EAAA","file":"LRDSETNH.cjs","sourcesContent":["export type HexString = `0x${string}`;\nexport type NormalizedHexString = Symbol;\nexport type HexStringIsTrimmed<T extends HexString> = T extends '0x0'\n ? true\n : T extends `0x0${string}`\n ? false\n : true;\n"]}
|
package/dist/LXPGE3ZL.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/strings.ts"],"names":[],"mappings":";;;AAAA,cAAA,EAAA","file":"LXPGE3ZL.js","sourcesContent":["/**\n * Guarantees that a string does not end with a suffix.\n * You can remove multiple suffixes by using a union.\n *\n * @example\n * type A = StringWithoutSuffix<'hello', 'world'>; // 'hello'\n * type B = StringWithoutSuffix<'hello', 'lo'>; // never\n * type C = StringWithoutSuffix<'hello world', 'lo' | 'world'>; // never\n */\nexport type StringWithoutSuffix<\n T extends string,\n Suffix extends string,\n> = T extends `${infer _}${Suffix}` ? never : T;\n"]}
|
package/dist/ODTE4REV.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/strings.ts"],"names":["init_cjs_shims"],"mappings":";;;;;AAAAA,2BAAA,EAAA","file":"ODTE4REV.cjs","sourcesContent":["/**\n * Guarantees that a string does not end with a suffix.\n * You can remove multiple suffixes by using a union.\n *\n * @example\n * type A = StringWithoutSuffix<'hello', 'world'>; // 'hello'\n * type B = StringWithoutSuffix<'hello', 'lo'>; // never\n * type C = StringWithoutSuffix<'hello world', 'lo' | 'world'>; // never\n */\nexport type StringWithoutSuffix<\n T extends string,\n Suffix extends string,\n> = T extends `${infer _}${Suffix}` ? never : T;\n"]}
|
package/dist/hexString.cjs
DELETED
package/dist/hexString.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"hexString.cjs"}
|
package/dist/hexString.d.ts
DELETED
package/dist/hexString.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hexString.d.ts","sourceRoot":"","sources":["../src/hexString.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,KAAK,MAAM,EAAE,CAAC;AACtC,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACzC,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,KAAK,GAC/D,IAAI,GACJ,CAAC,SAAS,MAAM,MAAM,EAAE,GACtB,KAAK,GACL,IAAI,CAAC"}
|
package/dist/hexString.js
DELETED
package/dist/hexString.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"hexString.js"}
|