@xylabs/hex 4.13.4 → 4.13.6
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/neutral/index.d.ts +78 -94
- package/package.json +5 -5
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,94 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export
|
|
78
|
-
|
|
79
|
-
export declare const toAddress: (value: string | number | bigint | ArrayBufferLike, config?: HexConfig) => Lowercase<string>;
|
|
80
|
-
|
|
81
|
-
/** takes any value and tries our best to convert it to a hex string */
|
|
82
|
-
export declare const toHex: (
|
|
83
|
-
/** Supported types are string, number, bigint, and ArrayBuffer */
|
|
84
|
-
value: string | number | bigint | ArrayBufferLike,
|
|
85
|
-
/** Configuration of output format and validation */
|
|
86
|
-
config?: HexConfig) => Lowercase<string>;
|
|
87
|
-
|
|
88
|
-
export declare const toHexLegacy: (buffer: ArrayBuffer) => string;
|
|
89
|
-
|
|
90
|
-
export declare const ZERO_ADDRESS: Address;
|
|
91
|
-
|
|
92
|
-
export declare const ZERO_HASH: Hash;
|
|
93
|
-
|
|
94
|
-
export { }
|
|
1
|
+
type AssertCallback = (value: unknown, message: string) => string | boolean;
|
|
2
|
+
type AssertConfig = string | AssertCallback | boolean;
|
|
3
|
+
|
|
4
|
+
type Hex = Exclude<Lowercase<string>, 'reserved-hex-value'>;
|
|
5
|
+
/** Configuration of validation and output format */
|
|
6
|
+
interface HexConfig {
|
|
7
|
+
bitLength?: number;
|
|
8
|
+
byteSize?: number;
|
|
9
|
+
prefix?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare function asHex(value: unknown): Hex | undefined;
|
|
13
|
+
declare function asHex(value: unknown, assert: AssertConfig): Hex;
|
|
14
|
+
|
|
15
|
+
/** Takes unknown value and tries our best to convert it to a hex string */
|
|
16
|
+
declare const hexFrom: (
|
|
17
|
+
/** Supported types are string, number, bigint, and ArrayBuffer */
|
|
18
|
+
value: string | number | bigint | ArrayBufferLike,
|
|
19
|
+
/** Configuration of output format and validation */
|
|
20
|
+
config?: HexConfig) => Hex;
|
|
21
|
+
|
|
22
|
+
/** Convert an ArrayBuffer to a hex string */
|
|
23
|
+
declare const hexFromArrayBuffer: (
|
|
24
|
+
/** The buffer to be converted */
|
|
25
|
+
buffer: ArrayBufferLike,
|
|
26
|
+
/** Configuration of output format and validation */
|
|
27
|
+
config?: HexConfig) => Hex;
|
|
28
|
+
|
|
29
|
+
/** Convert a bigint to a hex string */
|
|
30
|
+
declare const hexFromBigInt: (
|
|
31
|
+
/** The bigint to be converted */
|
|
32
|
+
value: bigint,
|
|
33
|
+
/** Configuration of output format and validation */
|
|
34
|
+
config?: HexConfig) => Hex;
|
|
35
|
+
|
|
36
|
+
declare const hexFromHexString: (value: string, config?: HexConfig) => Hex;
|
|
37
|
+
|
|
38
|
+
declare const hexFromNumber: (value: number, config?: HexConfig) => Hex;
|
|
39
|
+
|
|
40
|
+
declare const isHex: (value: unknown, config?: HexConfig) => value is Hex;
|
|
41
|
+
|
|
42
|
+
declare const isHexZero: (value?: string) => boolean | undefined;
|
|
43
|
+
|
|
44
|
+
declare const toHexLegacy: (buffer: ArrayBuffer) => string;
|
|
45
|
+
|
|
46
|
+
declare const bitsToNibbles: (value: number) => number;
|
|
47
|
+
declare const nibblesToBits: (value: number) => number;
|
|
48
|
+
|
|
49
|
+
declare const hexRegex: RegExp;
|
|
50
|
+
declare const hexRegexWithPrefix: RegExp;
|
|
51
|
+
|
|
52
|
+
/** takes any value and tries our best to convert it to a hex string */
|
|
53
|
+
declare const toHex: (
|
|
54
|
+
/** Supported types are string, number, bigint, and ArrayBuffer */
|
|
55
|
+
value: string | number | bigint | ArrayBufferLike,
|
|
56
|
+
/** Configuration of output format and validation */
|
|
57
|
+
config?: HexConfig) => Lowercase<string>;
|
|
58
|
+
|
|
59
|
+
type Address = Exclude<Hex, 'reserved-address-value'>;
|
|
60
|
+
declare const ZERO_ADDRESS: Address;
|
|
61
|
+
declare const toAddress: (value: string | number | bigint | ArrayBufferLike, config?: HexConfig) => Lowercase<string>;
|
|
62
|
+
declare const isAddress: (value: unknown, config?: HexConfig) => value is Address;
|
|
63
|
+
declare function asAddress(value: unknown): Address | undefined;
|
|
64
|
+
declare function asAddress(value: unknown, assert: AssertConfig): Address;
|
|
65
|
+
|
|
66
|
+
declare const ZERO_HASH: Hash;
|
|
67
|
+
type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
|
|
68
|
+
declare const HashBitLength: HashBitLength[];
|
|
69
|
+
declare const isHashBitLength: (value: unknown) => value is HashBitLength;
|
|
70
|
+
type Hash = Exclude<Hex, 'reserved-hash-value'>;
|
|
71
|
+
declare const isHash: (value: unknown, bitLength?: HashBitLength) => value is Hash;
|
|
72
|
+
declare function asHash(value: unknown): Hash | undefined;
|
|
73
|
+
declare function asHash(value: unknown, assert: AssertConfig): Hash;
|
|
74
|
+
|
|
75
|
+
declare function hexToBigInt(hex: Hex): bigint;
|
|
76
|
+
|
|
77
|
+
export { HashBitLength, ZERO_ADDRESS, ZERO_HASH, asAddress, asHash, asHex, bitsToNibbles, hexFrom, hexFromArrayBuffer, hexFromBigInt, hexFromHexString, hexFromNumber, hexRegex, hexRegexWithPrefix, hexToBigInt, isAddress, isHash, isHashBitLength, isHex, isHexZero, nibblesToBits, toAddress, toHex, toHexLegacy };
|
|
78
|
+
export type { Address, Hash, Hex, HexConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/hex",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.6",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hex",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"packages/**/*"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@xylabs/typeof": "^4.13.
|
|
42
|
+
"@xylabs/typeof": "^4.13.6"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.
|
|
46
|
-
"@xylabs/tsconfig": "^7.0.0-rc.
|
|
47
|
-
"@xylabs/vitest-extended": "^4.13.
|
|
45
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.8",
|
|
46
|
+
"@xylabs/tsconfig": "^7.0.0-rc.8",
|
|
47
|
+
"@xylabs/vitest-extended": "^4.13.6",
|
|
48
48
|
"typescript": "^5.8.3",
|
|
49
49
|
"vitest": "^3.2.4"
|
|
50
50
|
},
|