@xylabs/hex 5.0.84 → 5.0.86

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/README.md CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  Base functionality used throughout XY Labs TypeScript/JavaScript libraries
17
17
 
18
+
19
+
18
20
  ## Reference
19
21
 
20
22
  **@xylabs/hex**
@@ -23,77 +25,85 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
23
25
 
24
26
  ## Interfaces
25
27
 
26
- - [HexConfig](#interfaces/HexConfig)
28
+ | Interface | Description |
29
+ | ------ | ------ |
30
+ | [HexConfig](#interfaces/HexConfig) | Configuration of validation and output format |
27
31
 
28
32
  ## Type Aliases
29
33
 
30
- - [AddressTransformZodType](#type-aliases/AddressTransformZodType)
31
- - [AddressValidationZodType](#type-aliases/AddressValidationZodType)
32
- - [Address](#type-aliases/Address)
33
- - [EthAddress](#type-aliases/EthAddress)
34
- - [HashBitLength](#type-aliases/HashBitLength)
35
- - [BrandedHash](#type-aliases/BrandedHash)
36
- - [Hash](#type-aliases/Hash)
37
- - [BrandedHex](#type-aliases/BrandedHex)
38
- - [Hex](#type-aliases/Hex)
34
+ | Type Alias | Description |
35
+ | ------ | ------ |
36
+ | [AddressTransformZodType](#type-aliases/AddressTransformZodType) | The output type of AddressTransformZod after parsing and transformation. |
37
+ | [AddressValidationZodType](#type-aliases/AddressValidationZodType) | The output type of AddressValidationZod after parsing. |
38
+ | [Address](#type-aliases/Address) | A validated 20-byte address string type, inferred from the AddressZod schema. |
39
+ | [EthAddress](#type-aliases/EthAddress) | Branded type representing a validated Ethereum address with 0x prefix. |
40
+ | [HashBitLength](#type-aliases/HashBitLength) | Valid bit lengths for hash values. |
41
+ | [BrandedHash](#type-aliases/BrandedHash) | Branded type representing a validated hash hex string. |
42
+ | [Hash](#type-aliases/Hash) | A validated hash string type, inferred from the HashZod schema. |
43
+ | [BrandedHex](#type-aliases/BrandedHex) | Branded type representing a validated lowercase hex string. |
44
+ | [Hex](#type-aliases/Hex) | A validated hex string type, inferred from the HexZod schema. |
39
45
 
40
46
  ## Variables
41
47
 
42
- - [HexRegEx](#variables/HexRegEx)
43
- - [HexRegExWithPrefix](#variables/HexRegExWithPrefix)
44
- - [AddressTransformZod](#variables/AddressTransformZod)
45
- - [AddressValidationZod](#variables/AddressValidationZod)
46
- - [ZERO\_ADDRESS](#variables/ZERO_ADDRESS)
47
- - [ADDRESS\_LENGTH](#variables/ADDRESS_LENGTH)
48
- - [AddressRegEx](#variables/AddressRegEx)
49
- - [AddressZod](#variables/AddressZod)
50
- - [EthAddressRegEx](#variables/EthAddressRegEx)
51
- - [EthAddressToStringZod](#variables/EthAddressToStringZod)
52
- - [~~EthAddressToStringSchema~~](#variables/EthAddressToStringSchema)
53
- - [EthAddressFromStringZod](#variables/EthAddressFromStringZod)
54
- - [~~EthAddressFromStringSchema~~](#variables/EthAddressFromStringSchema)
55
- - [ETH\_ZERO\_ADDRESS](#variables/ETH_ZERO_ADDRESS)
56
- - [EthAddressZod](#variables/EthAddressZod)
57
- - [HASH\_LENGTH](#variables/HASH_LENGTH)
58
- - [HashRegEx](#variables/HashRegEx)
59
- - [ZERO\_HASH](#variables/ZERO_HASH)
60
- - [HashBitLength](#variables/HashBitLength)
61
- - [HashZod](#variables/HashZod)
62
- - [HashToJsonZod](#variables/HashToJsonZod)
63
- - [JsonToHashZod](#variables/JsonToHashZod)
64
- - [HexZod](#variables/HexZod)
65
- - [BigIntToJsonZod](#variables/BigIntToJsonZod)
66
- - [JsonToBigIntZod](#variables/JsonToBigIntZod)
48
+ | Variable | Description |
49
+ | ------ | ------ |
50
+ | [HexRegEx](#variables/HexRegEx) | Regular expression matching a lowercase hex string without prefix. |
51
+ | [HexRegExWithPrefix](#variables/HexRegExWithPrefix) | Regular expression matching a lowercase hex string with a 0x prefix. |
52
+ | [AddressTransformZod](#variables/AddressTransformZod) | Zod schema that accepts a string, bigint, or number and transforms it into a validated Address. |
53
+ | [AddressValidationZod](#variables/AddressValidationZod) | Zod schema that validates a string is a properly formatted 40-character hex address. |
54
+ | [ZERO\_ADDRESS](#variables/ZERO_ADDRESS) | A 160-bit zero address constant. |
55
+ | [ADDRESS\_LENGTH](#variables/ADDRESS_LENGTH) | The character length of an address hex string (40 hex characters / 20 bytes). |
56
+ | [AddressRegEx](#variables/AddressRegEx) | Regular expression matching a 20-byte (40 hex character) address string. |
57
+ | [AddressZod](#variables/AddressZod) | Zod schema that validates and transforms a string into a branded Address type. |
58
+ | [EthAddressRegEx](#variables/EthAddressRegEx) | Regular expression matching a 20-byte Ethereum address with 0x prefix (mixed case). |
59
+ | [EthAddressToStringZod](#variables/EthAddressToStringZod) | Zod schema that validates a string is a properly formatted Ethereum address. |
60
+ | [~~EthAddressToStringSchema~~](#variables/EthAddressToStringSchema) | - |
61
+ | [EthAddressFromStringZod](#variables/EthAddressFromStringZod) | Zod schema that validates and transforms a string into an EthAddress type. |
62
+ | [~~EthAddressFromStringSchema~~](#variables/EthAddressFromStringSchema) | - |
63
+ | [ETH\_ZERO\_ADDRESS](#variables/ETH_ZERO_ADDRESS) | The zero Ethereum address constant (0x followed by 40 zero characters). |
64
+ | [EthAddressZod](#variables/EthAddressZod) | Zod schema that validates a string as a properly formatted Ethereum address using regex and type guard. |
65
+ | [HASH\_LENGTH](#variables/HASH_LENGTH) | The byte length of a standard hash (32 bytes / 256 bits). |
66
+ | [HashRegEx](#variables/HashRegEx) | Regular expression matching a 32-byte (64 hex character) hash string. |
67
+ | [ZERO\_HASH](#variables/ZERO_HASH) | A 256-bit zero hash constant. |
68
+ | [HashBitLength](#variables/HashBitLength) | Array of all valid hash bit lengths for runtime validation. |
69
+ | [HashZod](#variables/HashZod) | Zod schema that validates and transforms a string into a branded Hash type. |
70
+ | [HashToJsonZod](#variables/HashToJsonZod) | Zod schema that transforms a Hash to a plain string for JSON serialization. |
71
+ | [JsonToHashZod](#variables/JsonToHashZod) | Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. |
72
+ | [HexZod](#variables/HexZod) | Zod schema that validates and transforms a string into a branded Hex type. |
73
+ | [BigIntToJsonZod](#variables/BigIntToJsonZod) | Zod schema that transforms a non-negative BigInt into a hex string for JSON serialization. |
74
+ | [JsonToBigIntZod](#variables/JsonToBigIntZod) | Zod schema that parses a JSON hex string into a BigInt. |
67
75
 
68
76
  ## Functions
69
77
 
70
- - [HexRegExMinMax](#functions/HexRegExMinMax)
71
- - [HexRegExMinMaxMixedCaseWithPrefix](#functions/HexRegExMinMaxMixedCaseWithPrefix)
72
- - [asAddress](#functions/asAddress)
73
- - [asAddressV2](#functions/asAddressV2)
74
- - [isAddress](#functions/isAddress)
75
- - [isAddressV2](#functions/isAddressV2)
76
- - [toAddress](#functions/toAddress)
77
- - [toAddressV2](#functions/toAddressV2)
78
- - [toEthAddress](#functions/toEthAddress)
79
- - [isEthAddress](#functions/isEthAddress)
80
- - [asEthAddress](#functions/asEthAddress)
81
- - [asHash](#functions/asHash)
82
- - [isHashBitLength](#functions/isHashBitLength)
83
- - [isHash](#functions/isHash)
84
- - [asHex](#functions/asHex)
85
- - [hexFrom](#functions/hexFrom)
86
- - [hexFromArrayBuffer](#functions/hexFromArrayBuffer)
87
- - [hexFromBigInt](#functions/hexFromBigInt)
88
- - [hexFromHexString](#functions/hexFromHexString)
89
- - [hexFromNumber](#functions/hexFromNumber)
90
- - [isHex](#functions/isHex)
91
- - [isHexZero](#functions/isHexZero)
92
- - [toHexLegacy](#functions/toHexLegacy)
93
- - [bitsToNibbles](#functions/bitsToNibbles)
94
- - [nibblesToBits](#functions/nibblesToBits)
95
- - [toHex](#functions/toHex)
96
- - [hexToBigInt](#functions/hexToBigInt)
78
+ | Function | Description |
79
+ | ------ | ------ |
80
+ | [HexRegExMinMax](#functions/HexRegExMinMax) | Creates a RegExp matching lowercase hex strings with a byte length in the given range. |
81
+ | [HexRegExMinMaxMixedCaseWithPrefix](#functions/HexRegExMinMaxMixedCaseWithPrefix) | Creates a RegExp matching mixed-case hex strings with a 0x prefix and a byte length in the given range. |
82
+ | [asAddress](#functions/asAddress) | Attempts to coerce a value into an Address type, returning undefined or throwing based on the assert config. |
83
+ | [asAddressV2](#functions/asAddressV2) | - |
84
+ | [isAddress](#functions/isAddress) | Type guard that checks whether a value is a valid 160-bit address. |
85
+ | [isAddressV2](#functions/isAddressV2) | - |
86
+ | [toAddress](#functions/toAddress) | Converts a value to a 160-bit Address hex string. |
87
+ | [toAddressV2](#functions/toAddressV2) | - |
88
+ | [toEthAddress](#functions/toEthAddress) | Converts a value to a 0x-prefixed Ethereum address string. |
89
+ | [isEthAddress](#functions/isEthAddress) | Type guard that checks whether a value is a valid 0x-prefixed Ethereum address. |
90
+ | [asEthAddress](#functions/asEthAddress) | Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config. |
91
+ | [asHash](#functions/asHash) | Attempts to coerce a value into a Hash type, returning undefined or throwing based on the assert config. |
92
+ | [isHashBitLength](#functions/isHashBitLength) | Type guard that checks whether a value is a valid hash bit length. |
93
+ | [isHash](#functions/isHash) | Type guard that checks whether a value is a valid hash of the specified bit length. |
94
+ | [asHex](#functions/asHex) | Attempts to coerce a value into a Hex type, returning undefined or throwing based on the assert config. |
95
+ | [hexFrom](#functions/hexFrom) | Takes unknown value and tries our best to convert it to a hex string |
96
+ | [hexFromArrayBuffer](#functions/hexFromArrayBuffer) | Convert an ArrayBuffer to a hex string |
97
+ | [hexFromBigInt](#functions/hexFromBigInt) | Convert a bigint to a hex string |
98
+ | [hexFromHexString](#functions/hexFromHexString) | Normalizes a hex string by stripping an optional 0x prefix, lowercasing, and padding to byte/bit boundaries. |
99
+ | [hexFromNumber](#functions/hexFromNumber) | Converts a number to a hex string by converting to BigInt first. |
100
+ | [isHex](#functions/isHex) | Type guard that checks whether a value is a valid hex string. |
101
+ | [isHexZero](#functions/isHexZero) | Checks whether a hex string represents a zero value. |
102
+ | [toHexLegacy](#functions/toHexLegacy) | Converts an ArrayBuffer to a hex string without padding or normalization. |
103
+ | [bitsToNibbles](#functions/bitsToNibbles) | Converts a bit count to the equivalent number of hex nibbles (4 bits each). |
104
+ | [nibblesToBits](#functions/nibblesToBits) | Converts a nibble count to the equivalent number of bits. |
105
+ | [toHex](#functions/toHex) | takes any value and tries our best to convert it to a hex string |
106
+ | [hexToBigInt](#functions/hexToBigInt) | Converts a Hex string to a BigInt. |
97
107
 
98
108
  ### functions
99
109
 
@@ -104,24 +114,17 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
104
114
  ***
105
115
 
106
116
  ```ts
107
- function HexRegExMinMax(minBytes?, maxBytes?): RegExp;
117
+ function HexRegExMinMax(minBytes?: number, maxBytes?: number): RegExp;
108
118
  ```
109
119
 
110
120
  Creates a RegExp matching lowercase hex strings with a byte length in the given range.
111
121
 
112
122
  ## Parameters
113
123
 
114
- ### minBytes?
115
-
116
- `number` = `0`
117
-
118
- Minimum number of bytes (default 0)
119
-
120
- ### maxBytes?
121
-
122
- `number` = `...`
123
-
124
- Maximum number of bytes
124
+ | Parameter | Type | Default value | Description |
125
+ | ------ | ------ | ------ | ------ |
126
+ | `minBytes` | `number` | `0` | Minimum number of bytes (default 0) |
127
+ | `maxBytes` | `number` | `...` | Maximum number of bytes |
125
128
 
126
129
  ## Returns
127
130
 
@@ -136,24 +139,17 @@ A RegExp for validating hex strings within the byte range
136
139
  ***
137
140
 
138
141
  ```ts
139
- function HexRegExMinMaxMixedCaseWithPrefix(minBytes?, maxBytes?): RegExp;
142
+ function HexRegExMinMaxMixedCaseWithPrefix(minBytes?: number, maxBytes?: number): RegExp;
140
143
  ```
141
144
 
142
145
  Creates a RegExp matching mixed-case hex strings with a 0x prefix and a byte length in the given range.
143
146
 
144
147
  ## Parameters
145
148
 
146
- ### minBytes?
147
-
148
- `number` = `0`
149
-
150
- Minimum number of bytes (default 0)
151
-
152
- ### maxBytes?
153
-
154
- `number` = `...`
155
-
156
- Maximum number of bytes
149
+ | Parameter | Type | Default value | Description |
150
+ | ------ | ------ | ------ | ------ |
151
+ | `minBytes` | `number` | `0` | Minimum number of bytes (default 0) |
152
+ | `maxBytes` | `number` | `...` | Maximum number of bytes |
157
153
 
158
154
  ## Returns
159
155
 
@@ -170,18 +166,16 @@ A RegExp for validating prefixed hex strings within the byte range
170
166
  ## Call Signature
171
167
 
172
168
  ```ts
173
- function asAddress(value): BrandedAddress | undefined;
169
+ function asAddress(value: unknown): BrandedAddress | undefined;
174
170
  ```
175
171
 
176
172
  Attempts to coerce a value into an Address type, returning undefined or throwing based on the assert config.
177
173
 
178
174
  ### Parameters
179
175
 
180
- ### value
181
-
182
- `unknown`
183
-
184
- The value to coerce (must be a string)
176
+ | Parameter | Type | Description |
177
+ | ------ | ------ | ------ |
178
+ | `value` | `unknown` | The value to coerce (must be a string) |
185
179
 
186
180
  ### Returns
187
181
 
@@ -192,24 +186,17 @@ The value as Address, or undefined if coercion fails and assert is not set
192
186
  ## Call Signature
193
187
 
194
188
  ```ts
195
- function asAddress(value, assert): BrandedAddress;
189
+ function asAddress(value: unknown, assert: AssertConfig): BrandedAddress;
196
190
  ```
197
191
 
198
192
  Attempts to coerce a value into an Address type, returning undefined or throwing based on the assert config.
199
193
 
200
194
  ### Parameters
201
195
 
202
- ### value
203
-
204
- `unknown`
205
-
206
- The value to coerce (must be a string)
207
-
208
- ### assert
209
-
210
- `AssertConfig`
211
-
212
- If provided, throws on failure instead of returning undefined
196
+ | Parameter | Type | Description |
197
+ | ------ | ------ | ------ |
198
+ | `value` | `unknown` | The value to coerce (must be a string) |
199
+ | `assert` | `AssertConfig` | If provided, throws on failure instead of returning undefined |
213
200
 
214
201
  ### Returns
215
202
 
@@ -224,20 +211,17 @@ The value as Address, or undefined if coercion fails and assert is not set
224
211
  ***
225
212
 
226
213
  ```ts
227
- function asAddressV2(value, assert?): BrandedAddress | undefined;
214
+ function asAddressV2(value: unknown, assert?: boolean): BrandedAddress | undefined;
228
215
  ```
229
216
 
230
217
  **`Alpha`**
231
218
 
232
219
  ## Parameters
233
220
 
234
- ### value
235
-
236
- `unknown`
237
-
238
- ### assert?
239
-
240
- `boolean` = `false`
221
+ | Parameter | Type | Default value |
222
+ | ------ | ------ | ------ |
223
+ | `value` | `unknown` | `undefined` |
224
+ | `assert` | `boolean` | `false` |
241
225
 
242
226
  ## Returns
243
227
 
@@ -252,18 +236,16 @@ function asAddressV2(value, assert?): BrandedAddress | undefined;
252
236
  ## Call Signature
253
237
 
254
238
  ```ts
255
- function asEthAddress(value): EthAddress | undefined;
239
+ function asEthAddress(value: unknown): EthAddress | undefined;
256
240
  ```
257
241
 
258
242
  Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config.
259
243
 
260
244
  ### Parameters
261
245
 
262
- ### value
263
-
264
- `unknown`
265
-
266
- The value to coerce (must be a string)
246
+ | Parameter | Type | Description |
247
+ | ------ | ------ | ------ |
248
+ | `value` | `unknown` | The value to coerce (must be a string) |
267
249
 
268
250
  ### Returns
269
251
 
@@ -274,24 +256,17 @@ The value as EthAddress, or undefined if coercion fails and assert is not set
274
256
  ## Call Signature
275
257
 
276
258
  ```ts
277
- function asEthAddress(value, assert): EthAddress;
259
+ function asEthAddress(value: unknown, assert: AssertConfig): EthAddress;
278
260
  ```
279
261
 
280
262
  Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config.
281
263
 
282
264
  ### Parameters
283
265
 
284
- ### value
285
-
286
- `unknown`
287
-
288
- The value to coerce (must be a string)
289
-
290
- ### assert
291
-
292
- `AssertConfig`
293
-
294
- If provided, throws on failure instead of returning undefined
266
+ | Parameter | Type | Description |
267
+ | ------ | ------ | ------ |
268
+ | `value` | `unknown` | The value to coerce (must be a string) |
269
+ | `assert` | `AssertConfig` | If provided, throws on failure instead of returning undefined |
295
270
 
296
271
  ### Returns
297
272
 
@@ -308,18 +283,16 @@ The value as EthAddress, or undefined if coercion fails and assert is not set
308
283
  ## Call Signature
309
284
 
310
285
  ```ts
311
- function asHash(value): BrandedHash | undefined;
286
+ function asHash(value: unknown): BrandedHash | undefined;
312
287
  ```
313
288
 
314
289
  Attempts to coerce a value into a Hash type, returning undefined or throwing based on the assert config.
315
290
 
316
291
  ### Parameters
317
292
 
318
- ### value
319
-
320
- `unknown`
321
-
322
- The value to coerce (must be a string)
293
+ | Parameter | Type | Description |
294
+ | ------ | ------ | ------ |
295
+ | `value` | `unknown` | The value to coerce (must be a string) |
323
296
 
324
297
  ### Returns
325
298
 
@@ -330,24 +303,17 @@ The value as Hash, or undefined if coercion fails and assert is not set
330
303
  ## Call Signature
331
304
 
332
305
  ```ts
333
- function asHash(value, assert): BrandedHash;
306
+ function asHash(value: unknown, assert: AssertConfig): BrandedHash;
334
307
  ```
335
308
 
336
309
  Attempts to coerce a value into a Hash type, returning undefined or throwing based on the assert config.
337
310
 
338
311
  ### Parameters
339
312
 
340
- ### value
341
-
342
- `unknown`
343
-
344
- The value to coerce (must be a string)
345
-
346
- ### assert
347
-
348
- `AssertConfig`
349
-
350
- If provided, throws on failure instead of returning undefined
313
+ | Parameter | Type | Description |
314
+ | ------ | ------ | ------ |
315
+ | `value` | `unknown` | The value to coerce (must be a string) |
316
+ | `assert` | `AssertConfig` | If provided, throws on failure instead of returning undefined |
351
317
 
352
318
  ### Returns
353
319
 
@@ -364,18 +330,16 @@ The value as Hash, or undefined if coercion fails and assert is not set
364
330
  ## Call Signature
365
331
 
366
332
  ```ts
367
- function asHex(value): BrandedHex | undefined;
333
+ function asHex(value: unknown): BrandedHex | undefined;
368
334
  ```
369
335
 
370
336
  Attempts to coerce a value into a Hex type, returning undefined or throwing based on the assert config.
371
337
 
372
338
  ### Parameters
373
339
 
374
- ### value
375
-
376
- `unknown`
377
-
378
- The value to coerce (must be a string)
340
+ | Parameter | Type | Description |
341
+ | ------ | ------ | ------ |
342
+ | `value` | `unknown` | The value to coerce (must be a string) |
379
343
 
380
344
  ### Returns
381
345
 
@@ -386,24 +350,17 @@ The value as Hex, or undefined if coercion fails and assert is not set
386
350
  ## Call Signature
387
351
 
388
352
  ```ts
389
- function asHex(value, assert): BrandedHex;
353
+ function asHex(value: unknown, assert: AssertConfig): BrandedHex;
390
354
  ```
391
355
 
392
356
  Attempts to coerce a value into a Hex type, returning undefined or throwing based on the assert config.
393
357
 
394
358
  ### Parameters
395
359
 
396
- ### value
397
-
398
- `unknown`
399
-
400
- The value to coerce (must be a string)
401
-
402
- ### assert
403
-
404
- `AssertConfig`
405
-
406
- If provided, throws on failure instead of returning undefined
360
+ | Parameter | Type | Description |
361
+ | ------ | ------ | ------ |
362
+ | `value` | `unknown` | The value to coerce (must be a string) |
363
+ | `assert` | `AssertConfig` | If provided, throws on failure instead of returning undefined |
407
364
 
408
365
  ### Returns
409
366
 
@@ -418,18 +375,16 @@ The value as Hex, or undefined if coercion fails and assert is not set
418
375
  ***
419
376
 
420
377
  ```ts
421
- function bitsToNibbles(value): number;
378
+ function bitsToNibbles(value: number): number;
422
379
  ```
423
380
 
424
381
  Converts a bit count to the equivalent number of hex nibbles (4 bits each).
425
382
 
426
383
  ## Parameters
427
384
 
428
- ### value
429
-
430
- `number`
431
-
432
- The number of bits (must be a multiple of 4)
385
+ | Parameter | Type | Description |
386
+ | ------ | ------ | ------ |
387
+ | `value` | `number` | The number of bits (must be a multiple of 4) |
433
388
 
434
389
  ## Returns
435
390
 
@@ -444,24 +399,17 @@ The number of nibbles
444
399
  ***
445
400
 
446
401
  ```ts
447
- function hexFrom(value, config?): BrandedHex;
402
+ function hexFrom(value: string | number | bigint | ArrayBufferLike, config?: HexConfig): BrandedHex;
448
403
  ```
449
404
 
450
405
  Takes unknown value and tries our best to convert it to a hex string
451
406
 
452
407
  ## Parameters
453
408
 
454
- ### value
455
-
456
- Supported types are string, number, bigint, and ArrayBuffer
457
-
458
- `string` | `number` | `bigint` | `ArrayBufferLike`
459
-
460
- ### config?
461
-
462
- [`HexConfig`](#../interfaces/HexConfig)
463
-
464
- Configuration of output format and validation
409
+ | Parameter | Type | Description |
410
+ | ------ | ------ | ------ |
411
+ | `value` | `string` \| `number` \| `bigint` \| `ArrayBufferLike` | Supported types are string, number, bigint, and ArrayBuffer |
412
+ | `config?` | [`HexConfig`](#../interfaces/HexConfig) | Configuration of output format and validation |
465
413
 
466
414
  ## Returns
467
415
 
@@ -474,24 +422,17 @@ Configuration of output format and validation
474
422
  ***
475
423
 
476
424
  ```ts
477
- function hexFromArrayBuffer(buffer, config?): BrandedHex;
425
+ function hexFromArrayBuffer(buffer: ArrayBufferLike, config?: HexConfig): BrandedHex;
478
426
  ```
479
427
 
480
428
  Convert an ArrayBuffer to a hex string
481
429
 
482
430
  ## Parameters
483
431
 
484
- ### buffer
485
-
486
- `ArrayBufferLike`
487
-
488
- The buffer to be converted
489
-
490
- ### config?
491
-
492
- [`HexConfig`](#../interfaces/HexConfig)
493
-
494
- Configuration of output format and validation
432
+ | Parameter | Type | Description |
433
+ | ------ | ------ | ------ |
434
+ | `buffer` | `ArrayBufferLike` | The buffer to be converted |
435
+ | `config?` | [`HexConfig`](#../interfaces/HexConfig) | Configuration of output format and validation |
495
436
 
496
437
  ## Returns
497
438
 
@@ -504,24 +445,17 @@ Configuration of output format and validation
504
445
  ***
505
446
 
506
447
  ```ts
507
- function hexFromBigInt(value, config?): BrandedHex;
448
+ function hexFromBigInt(value: bigint, config?: HexConfig): BrandedHex;
508
449
  ```
509
450
 
510
451
  Convert a bigint to a hex string
511
452
 
512
453
  ## Parameters
513
454
 
514
- ### value
515
-
516
- `bigint`
517
-
518
- The bigint to be converted
519
-
520
- ### config?
521
-
522
- [`HexConfig`](#../interfaces/HexConfig) = `{}`
523
-
524
- Configuration of output format and validation
455
+ | Parameter | Type | Description |
456
+ | ------ | ------ | ------ |
457
+ | `value` | `bigint` | The bigint to be converted |
458
+ | `config` | [`HexConfig`](#../interfaces/HexConfig) | Configuration of output format and validation |
525
459
 
526
460
  ## Returns
527
461
 
@@ -534,24 +468,17 @@ Configuration of output format and validation
534
468
  ***
535
469
 
536
470
  ```ts
537
- function hexFromHexString(value, config?): BrandedHex;
471
+ function hexFromHexString(value: string, config?: HexConfig): BrandedHex;
538
472
  ```
539
473
 
540
474
  Normalizes a hex string by stripping an optional 0x prefix, lowercasing, and padding to byte/bit boundaries.
541
475
 
542
476
  ## Parameters
543
477
 
544
- ### value
545
-
546
- `string`
547
-
548
- The hex string to normalize (with or without 0x prefix)
549
-
550
- ### config?
551
-
552
- [`HexConfig`](#../interfaces/HexConfig) = `{}`
553
-
554
- Configuration for prefix, byteSize, and bitLength padding
478
+ | Parameter | Type | Description |
479
+ | ------ | ------ | ------ |
480
+ | `value` | `string` | The hex string to normalize (with or without 0x prefix) |
481
+ | `config` | [`HexConfig`](#../interfaces/HexConfig) | Configuration for prefix, byteSize, and bitLength padding |
555
482
 
556
483
  ## Returns
557
484
 
@@ -566,24 +493,17 @@ The normalized Hex string
566
493
  ***
567
494
 
568
495
  ```ts
569
- function hexFromNumber(value, config?): BrandedHex;
496
+ function hexFromNumber(value: number, config?: HexConfig): BrandedHex;
570
497
  ```
571
498
 
572
499
  Converts a number to a hex string by converting to BigInt first.
573
500
 
574
501
  ## Parameters
575
502
 
576
- ### value
577
-
578
- `number`
579
-
580
- The number to convert
581
-
582
- ### config?
583
-
584
- [`HexConfig`](#../interfaces/HexConfig)
585
-
586
- Optional hex output configuration
503
+ | Parameter | Type | Description |
504
+ | ------ | ------ | ------ |
505
+ | `value` | `number` | The number to convert |
506
+ | `config?` | [`HexConfig`](#../interfaces/HexConfig) | Optional hex output configuration |
587
507
 
588
508
  ## Returns
589
509
 
@@ -598,18 +518,16 @@ The hex string representation
598
518
  ***
599
519
 
600
520
  ```ts
601
- function hexToBigInt(hex): bigint;
521
+ function hexToBigInt(hex: BrandedHex): bigint;
602
522
  ```
603
523
 
604
524
  Converts a Hex string to a BigInt.
605
525
 
606
526
  ## Parameters
607
527
 
608
- ### hex
609
-
610
- [`BrandedHex`](#../type-aliases/BrandedHex)
611
-
612
- The hex string to convert
528
+ | Parameter | Type | Description |
529
+ | ------ | ------ | ------ |
530
+ | `hex` | [`BrandedHex`](#../type-aliases/BrandedHex) | The hex string to convert |
613
531
 
614
532
  ## Returns
615
533
 
@@ -624,24 +542,17 @@ The BigInt representation of the hex value
624
542
  ***
625
543
 
626
544
  ```ts
627
- function isAddress(value, config?): value is BrandedAddress;
545
+ function isAddress(value: unknown, config?: HexConfig): value is BrandedAddress;
628
546
  ```
629
547
 
630
548
  Type guard that checks whether a value is a valid 160-bit address.
631
549
 
632
550
  ## Parameters
633
551
 
634
- ### value
635
-
636
- `unknown`
637
-
638
- The value to check
639
-
640
- ### config?
641
-
642
- [`HexConfig`](#../interfaces/HexConfig) = `{}`
643
-
644
- Optional hex config (defaults to 160-bit, no prefix)
552
+ | Parameter | Type | Description |
553
+ | ------ | ------ | ------ |
554
+ | `value` | `unknown` | The value to check |
555
+ | `config` | [`HexConfig`](#../interfaces/HexConfig) | Optional hex config (defaults to 160-bit, no prefix) |
645
556
 
646
557
  ## Returns
647
558
 
@@ -656,16 +567,16 @@ True if the value is a valid Address
656
567
  ***
657
568
 
658
569
  ```ts
659
- function isAddressV2(value): value is BrandedAddress;
570
+ function isAddressV2(value: unknown): value is BrandedAddress;
660
571
  ```
661
572
 
662
573
  **`Alpha`**
663
574
 
664
575
  ## Parameters
665
576
 
666
- ### value
667
-
668
- `unknown`
577
+ | Parameter | Type |
578
+ | ------ | ------ |
579
+ | `value` | `unknown` |
669
580
 
670
581
  ## Returns
671
582
 
@@ -678,24 +589,17 @@ function isAddressV2(value): value is BrandedAddress;
678
589
  ***
679
590
 
680
591
  ```ts
681
- function isEthAddress(value, config?): value is EthAddress;
592
+ function isEthAddress(value: unknown, config?: HexConfig): value is EthAddress;
682
593
  ```
683
594
 
684
595
  Type guard that checks whether a value is a valid 0x-prefixed Ethereum address.
685
596
 
686
597
  ## Parameters
687
598
 
688
- ### value
689
-
690
- `unknown`
691
-
692
- The value to check
693
-
694
- ### config?
695
-
696
- [`HexConfig`](#../interfaces/HexConfig) = `{}`
697
-
698
- Optional hex config (defaults to 160-bit with prefix)
599
+ | Parameter | Type | Description |
600
+ | ------ | ------ | ------ |
601
+ | `value` | `unknown` | The value to check |
602
+ | `config` | [`HexConfig`](#../interfaces/HexConfig) | Optional hex config (defaults to 160-bit with prefix) |
699
603
 
700
604
  ## Returns
701
605
 
@@ -710,24 +614,17 @@ True if the value is a valid EthAddress
710
614
  ***
711
615
 
712
616
  ```ts
713
- function isHash(value, bitLength?): value is BrandedHash;
617
+ function isHash(value: unknown, bitLength?: HashBitLength): value is BrandedHash;
714
618
  ```
715
619
 
716
620
  Type guard that checks whether a value is a valid hash of the specified bit length.
717
621
 
718
622
  ## Parameters
719
623
 
720
- ### value
721
-
722
- `unknown`
723
-
724
- The value to check
725
-
726
- ### bitLength?
727
-
728
- [`HashBitLength`](#../type-aliases/HashBitLength) = `256`
729
-
730
- The expected bit length of the hash (defaults to 256)
624
+ | Parameter | Type | Default value | Description |
625
+ | ------ | ------ | ------ | ------ |
626
+ | `value` | `unknown` | `undefined` | The value to check |
627
+ | `bitLength` | [`HashBitLength`](#../type-aliases/HashBitLength) | `256` | The expected bit length of the hash (defaults to 256) |
731
628
 
732
629
  ## Returns
733
630
 
@@ -742,18 +639,16 @@ True if the value is a valid Hash
742
639
  ***
743
640
 
744
641
  ```ts
745
- function isHashBitLength(value): value is HashBitLength;
642
+ function isHashBitLength(value: unknown): value is HashBitLength;
746
643
  ```
747
644
 
748
645
  Type guard that checks whether a value is a valid hash bit length.
749
646
 
750
647
  ## Parameters
751
648
 
752
- ### value
753
-
754
- `unknown`
755
-
756
- The value to check
649
+ | Parameter | Type | Description |
650
+ | ------ | ------ | ------ |
651
+ | `value` | `unknown` | The value to check |
757
652
 
758
653
  ## Returns
759
654
 
@@ -768,24 +663,17 @@ True if the value is one of the supported HashBitLength values
768
663
  ***
769
664
 
770
665
  ```ts
771
- function isHex(value, config?): value is BrandedHex;
666
+ function isHex(value: unknown, config?: HexConfig): value is BrandedHex;
772
667
  ```
773
668
 
774
669
  Type guard that checks whether a value is a valid hex string.
775
670
 
776
671
  ## Parameters
777
672
 
778
- ### value
779
-
780
- `unknown`
781
-
782
- The value to check
783
-
784
- ### config?
785
-
786
- [`HexConfig`](#../interfaces/HexConfig)
787
-
788
- Optional configuration for prefix and bit length validation
673
+ | Parameter | Type | Description |
674
+ | ------ | ------ | ------ |
675
+ | `value` | `unknown` | The value to check |
676
+ | `config?` | [`HexConfig`](#../interfaces/HexConfig) | Optional configuration for prefix and bit length validation |
789
677
 
790
678
  ## Returns
791
679
 
@@ -800,18 +688,16 @@ True if the value is a valid Hex string
800
688
  ***
801
689
 
802
690
  ```ts
803
- function isHexZero(value?): boolean | undefined;
691
+ function isHexZero(value?: string): boolean | undefined;
804
692
  ```
805
693
 
806
694
  Checks whether a hex string represents a zero value.
807
695
 
808
696
  ## Parameters
809
697
 
810
- ### value?
811
-
812
- `string`
813
-
814
- The hex string to check
698
+ | Parameter | Type | Description |
699
+ | ------ | ------ | ------ |
700
+ | `value?` | `string` | The hex string to check |
815
701
 
816
702
  ## Returns
817
703
 
@@ -826,18 +712,16 @@ True if zero, false if non-zero, or undefined if the input is not a string
826
712
  ***
827
713
 
828
714
  ```ts
829
- function nibblesToBits(value): number;
715
+ function nibblesToBits(value: number): number;
830
716
  ```
831
717
 
832
718
  Converts a nibble count to the equivalent number of bits.
833
719
 
834
720
  ## Parameters
835
721
 
836
- ### value
837
-
838
- `number`
839
-
840
- The number of nibbles
722
+ | Parameter | Type | Description |
723
+ | ------ | ------ | ------ |
724
+ | `value` | `number` | The number of nibbles |
841
725
 
842
726
  ## Returns
843
727
 
@@ -852,24 +736,17 @@ The number of bits
852
736
  ***
853
737
 
854
738
  ```ts
855
- function toAddress(value, config?): BrandedAddress;
739
+ function toAddress(value: string | number | bigint | ArrayBufferLike, config?: HexConfig): BrandedAddress;
856
740
  ```
857
741
 
858
742
  Converts a value to a 160-bit Address hex string.
859
743
 
860
744
  ## Parameters
861
745
 
862
- ### value
863
-
864
- The value to convert (string, number, bigint, or ArrayBuffer)
865
-
866
- `string` | `number` | `bigint` | `ArrayBufferLike`
867
-
868
- ### config?
869
-
870
- [`HexConfig`](#../interfaces/HexConfig) = `{}`
871
-
872
- Optional hex config (defaults to 160-bit, no prefix)
746
+ | Parameter | Type | Description |
747
+ | ------ | ------ | ------ |
748
+ | `value` | `string` \| `number` \| `bigint` \| `ArrayBufferLike` | The value to convert (string, number, bigint, or ArrayBuffer) |
749
+ | `config` | [`HexConfig`](#../interfaces/HexConfig) | Optional hex config (defaults to 160-bit, no prefix) |
873
750
 
874
751
  ## Returns
875
752
 
@@ -884,20 +761,17 @@ The value as an Address
884
761
  ***
885
762
 
886
763
  ```ts
887
- function toAddressV2(value, assert?): BrandedAddress | undefined;
764
+ function toAddressV2(value: unknown, assert?: boolean): BrandedAddress | undefined;
888
765
  ```
889
766
 
890
767
  **`Alpha`**
891
768
 
892
769
  ## Parameters
893
770
 
894
- ### value
895
-
896
- `unknown`
897
-
898
- ### assert?
899
-
900
- `boolean` = `false`
771
+ | Parameter | Type | Default value |
772
+ | ------ | ------ | ------ |
773
+ | `value` | `unknown` | `undefined` |
774
+ | `assert` | `boolean` | `false` |
901
775
 
902
776
  ## Returns
903
777
 
@@ -910,24 +784,17 @@ function toAddressV2(value, assert?): BrandedAddress | undefined;
910
784
  ***
911
785
 
912
786
  ```ts
913
- function toEthAddress(value, config?): EthAddress;
787
+ function toEthAddress(value: string | number | bigint | ArrayBufferLike, config?: HexConfig): EthAddress;
914
788
  ```
915
789
 
916
790
  Converts a value to a 0x-prefixed Ethereum address string.
917
791
 
918
792
  ## Parameters
919
793
 
920
- ### value
921
-
922
- The value to convert (string, number, bigint, or ArrayBuffer)
923
-
924
- `string` | `number` | `bigint` | `ArrayBufferLike`
925
-
926
- ### config?
927
-
928
- [`HexConfig`](#../interfaces/HexConfig) = `{}`
929
-
930
- Optional hex config (defaults to 160-bit, no inner prefix)
794
+ | Parameter | Type | Description |
795
+ | ------ | ------ | ------ |
796
+ | `value` | `string` \| `number` \| `bigint` \| `ArrayBufferLike` | The value to convert (string, number, bigint, or ArrayBuffer) |
797
+ | `config` | [`HexConfig`](#../interfaces/HexConfig) | Optional hex config (defaults to 160-bit, no inner prefix) |
931
798
 
932
799
  ## Returns
933
800
 
@@ -942,24 +809,17 @@ The value as an EthAddress
942
809
  ***
943
810
 
944
811
  ```ts
945
- function toHex(value, config?): BrandedHex;
812
+ function toHex(value: string | number | bigint | ArrayBufferLike, config?: HexConfig): BrandedHex;
946
813
  ```
947
814
 
948
815
  takes any value and tries our best to convert it to a hex string
949
816
 
950
817
  ## Parameters
951
818
 
952
- ### value
953
-
954
- Supported types are string, number, bigint, and ArrayBuffer
955
-
956
- `string` | `number` | `bigint` | `ArrayBufferLike`
957
-
958
- ### config?
959
-
960
- [`HexConfig`](#../interfaces/HexConfig) = `{}`
961
-
962
- Configuration of output format and validation
819
+ | Parameter | Type | Description |
820
+ | ------ | ------ | ------ |
821
+ | `value` | `string` \| `number` \| `bigint` \| `ArrayBufferLike` | Supported types are string, number, bigint, and ArrayBuffer |
822
+ | `config` | [`HexConfig`](#../interfaces/HexConfig) | Configuration of output format and validation |
963
823
 
964
824
  ## Returns
965
825
 
@@ -972,18 +832,16 @@ Configuration of output format and validation
972
832
  ***
973
833
 
974
834
  ```ts
975
- function toHexLegacy(buffer): string;
835
+ function toHexLegacy(buffer: ArrayBuffer): string;
976
836
  ```
977
837
 
978
838
  Converts an ArrayBuffer to a hex string without padding or normalization.
979
839
 
980
840
  ## Parameters
981
841
 
982
- ### buffer
983
-
984
- `ArrayBuffer`
985
-
986
- The ArrayBuffer to convert
842
+ | Parameter | Type | Description |
843
+ | ------ | ------ | ------ |
844
+ | `buffer` | `ArrayBuffer` | The ArrayBuffer to convert |
987
845
 
988
846
  ## Returns
989
847
 
@@ -1003,27 +861,11 @@ Configuration of validation and output format
1003
861
 
1004
862
  ## Properties
1005
863
 
1006
- ### bitLength?
1007
-
1008
- ```ts
1009
- optional bitLength: number;
1010
- ```
1011
-
1012
- ***
1013
-
1014
- ### byteSize?
1015
-
1016
- ```ts
1017
- optional byteSize: number;
1018
- ```
1019
-
1020
- ***
1021
-
1022
- ### prefix?
1023
-
1024
- ```ts
1025
- optional prefix: boolean;
1026
- ```
864
+ | Property | Type |
865
+ | ------ | ------ |
866
+ | <a id="bitlength"></a> `bitLength?` | `number` |
867
+ | <a id="bytesize"></a> `byteSize?` | `number` |
868
+ | <a id="prefix"></a> `prefix?` | `boolean` |
1027
869
 
1028
870
  ### type-aliases
1029
871
 
@@ -6,7 +6,7 @@ import type { Address } from './address.ts';
6
6
  * @param config - Optional hex config (defaults to 160-bit, no prefix)
7
7
  * @returns True if the value is a valid Address
8
8
  */
9
- export declare const isAddress: (value: unknown, config?: HexConfig) => value is Address;
9
+ export declare const isAddress: (value?: unknown, config?: HexConfig) => value is Address;
10
10
  /** @alpha */
11
- export declare function isAddressV2(value: unknown): value is Address;
11
+ export declare function isAddressV2(value?: unknown): value is Address;
12
12
  //# sourceMappingURL=is.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/address/is.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,OAG3E,CAAA;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE5D"}
1
+ {"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/address/is.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,OAAO,EAAE,SAAQ,SAAc,KAAG,KAAK,IAAI,OAG5E,CAAA;AAED,aAAa;AACb,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE7D"}
@@ -140,7 +140,7 @@ var toHex = (value, config = {}) => {
140
140
  };
141
141
 
142
142
  // src/address/AddressValidationZod.ts
143
- var AddressValidationZod = z3.string().refine((x) => HexZod.safeParse(x)).refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${e.input}]`) }).transform((v) => v);
143
+ var AddressValidationZod = z3.string().refine((x) => HexZod.safeParse(x).success).refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${e.input}]`) }).transform((v) => v);
144
144
 
145
145
  // src/address/AddressTransformZod.ts
146
146
  var AddressTransformZod = z4.union([z4.string(), z4.bigint(), z4.number()]).transform((value) => {
@@ -179,7 +179,7 @@ function asAddress(value, assert) {
179
179
  let stringValue = void 0;
180
180
  switch (typeof value) {
181
181
  case "string": {
182
- stringValue = hexFromHexString(value, { prefix: false });
182
+ stringValue = hexFromHexString(value, { prefix: false, byteSize: 4 });
183
183
  break;
184
184
  }
185
185
  default: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/address/address.ts","../../src/HexRegEx.ts","../../src/address/AddressTransformZod.ts","../../src/address/AddressValidationZod.ts","../../src/hex/as.ts","../../src/hex/from/fromHexString.ts","../../src/hex/nibble.ts","../../src/hex/is.ts","../../src/hex/from/fromArrayBuffer.ts","../../src/hex/from/fromBigInt.ts","../../src/hex/from/fromNumber.ts","../../src/hex/from/from.ts","../../src/hex/hex.ts","../../src/hex/isHexZero.ts","../../src/hex/legacy.ts","../../src/hex/to.ts","../../src/address/as.ts","../../src/address/is.ts","../../src/address/to.ts","../../src/ethAddress.ts","../../src/hash/as.ts","../../src/hash/is.ts","../../src/hash/hash.ts","../../src/hash/zod.ts","../../src/hexToBigInt.ts","../../src/zod.ts"],"sourcesContent":["import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { type Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\n/** A 160-bit zero address constant. */\nexport const ZERO_ADDRESS = '0000000000000000000000000000000000000000' as Address\n/** The character length of an address hex string (40 hex characters / 20 bytes). */\nexport const ADDRESS_LENGTH = 40 as const\n\n/** Regular expression matching a 20-byte (40 hex character) address string. */\nexport const AddressRegEx = HexRegExMinMax(ADDRESS_LENGTH / 2, ADDRESS_LENGTH / 2)\n\ntype BrandedAddress = Brand<Hex, { readonly __address: true }>\n\n/** Zod schema that validates and transforms a string into a branded Address type. */\nexport const AddressZod = z.string().regex(AddressRegEx).transform<BrandedAddress>(v => v as BrandedAddress)\n\n/** A validated 20-byte address string type, inferred from the AddressZod schema. */\nexport type Address = z.infer<typeof AddressZod>\n","/**\n * Creates a RegExp matching lowercase hex strings with a byte length in the given range.\n * @param minBytes - Minimum number of bytes (default 0)\n * @param maxBytes - Maximum number of bytes\n * @returns A RegExp for validating hex strings within the byte range\n */\nexport const HexRegExMinMax = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^[a-f0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\n/**\n * Creates a RegExp matching mixed-case hex strings with a 0x prefix and a byte length in the given range.\n * @param minBytes - Minimum number of bytes (default 0)\n * @param maxBytes - Maximum number of bytes\n * @returns A RegExp for validating prefixed hex strings within the byte range\n */\nexport const HexRegExMinMaxMixedCaseWithPrefix = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^0x[a-fA-F0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\n/** Regular expression matching a lowercase hex string without prefix. */\nexport const HexRegEx = /^[0-9a-f]+$/\n/** Regular expression matching a lowercase hex string with a 0x prefix. */\nexport const HexRegExWithPrefix = /^0x[0-9a-f]+$/\n","import * as z from 'zod'\n\nimport { type Address, ADDRESS_LENGTH } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\n/** Zod schema that accepts a string, bigint, or number and transforms it into a validated Address. */\nexport const AddressTransformZod = z.union([z.string(), z.bigint(), z.number()])\n .transform((value) => {\n switch (typeof value) {\n case 'bigint': {\n return value.toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n case 'string': {\n if (value.startsWith('0x')) {\n return value.slice(2)\n }\n return value\n }\n case 'number': {\n return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n }\n })\n .refine(x => AddressValidationZod.safeParse(x).data)\n .transform(x => x as Address)\n\n/** The output type of AddressTransformZod after parsing and transformation. */\nexport type AddressTransformZodType = z.infer<typeof AddressTransformZod>\n","import * as z from 'zod'\n\nimport { HexZod } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { ADDRESS_LENGTH } from './address.ts'\n\n/** Zod schema that validates a string is a properly formatted 40-character hex address. */\nexport const AddressValidationZod = z.string()\n .refine(x => HexZod.safeParse(x))\n .refine(x => x.length === ADDRESS_LENGTH, { error: e => new Error(`Address must have 40 characters [${e.input}]`) })\n .transform(v => v as Address)\n\n/** The output type of AddressValidationZod after parsing. */\nexport type AddressValidationZodType = z.infer<typeof AddressValidationZod>\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\n\nimport { hexFromHexString } from './from/index.ts'\nimport type { Hex } from './hex.ts'\nimport { isHex } from './is.ts'\n\n/**\n * Attempts to coerce a value into a Hex type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Hex, or undefined if coercion fails and assert is not set\n */\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, assert?: AssertConfig): Hex | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n\n return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`)\n}\n","import { isNumber } from '@xylabs/typeof'\n\nimport type { Hex, HexConfig } from '../hex.ts'\nimport { isHex } from '../is.ts'\nimport { bitsToNibbles } from '../nibble.ts'\n\n/**\n * Normalizes a hex string by stripping an optional 0x prefix, lowercasing, and padding to byte/bit boundaries.\n * @param value - The hex string to normalize (with or without 0x prefix)\n * @param config - Configuration for prefix, byteSize, and bitLength padding\n * @returns The normalized Hex string\n */\nexport const hexFromHexString = (value: string, config: HexConfig = {}): Hex => {\n const {\n prefix = false, byteSize = 8, bitLength,\n } = config\n const nibbleBoundary = bitsToNibbles(byteSize)\n const unEvened = (value.startsWith('0x') ? value.slice(2) : value).toLowerCase()\n if (isHex(unEvened)) {\n const evenCharacters = unEvened.padStart(Math.ceil(unEvened.length / nibbleBoundary) * nibbleBoundary, '0')\n const padded = isNumber(bitLength) ? evenCharacters.padStart(bitLength / 4, '0') : evenCharacters\n return (prefix ? `0x${padded}` : padded).toLowerCase() as Hex\n } else {\n throw new Error('Received string is not a value hex')\n }\n}\n","/**\n * Converts a bit count to the equivalent number of hex nibbles (4 bits each).\n * @param value - The number of bits (must be a multiple of 4)\n * @returns The number of nibbles\n */\nexport const bitsToNibbles = (value: number): number => {\n const nibbles = value >> 2\n if (value !== nibbles << 2) throw new Error('Bits for nibbles must multiple of 4')\n return nibbles\n}\n\n/**\n * Converts a nibble count to the equivalent number of bits.\n * @param value - The number of nibbles\n * @returns The number of bits\n */\nexport const nibblesToBits = (value: number): number => {\n return value << 2\n}\n","import { HexRegEx, HexRegExWithPrefix } from '../HexRegEx.ts'\nimport type { Hex, HexConfig } from './hex.ts'\nimport { bitsToNibbles } from './nibble.ts'\n\n/**\n * Type guard that checks whether a value is a valid hex string.\n * @param value - The value to check\n * @param config - Optional configuration for prefix and bit length validation\n * @returns True if the value is a valid Hex string\n */\nexport const isHex = (value: unknown, config?: HexConfig): value is Hex => {\n // Is it a string?\n if (typeof value !== 'string') return false\n\n const valueCharLength = config?.prefix ? value.length - 2 : value.length\n\n // If a bitLength specified, does it conform?\n if (config?.bitLength !== undefined && valueCharLength !== bitsToNibbles(config?.bitLength)) return false\n\n // Does it only has hex values?\n return config?.prefix ? HexRegExWithPrefix.test(value) : HexRegEx.test(value)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert an ArrayBuffer to a hex string */\nexport const hexFromArrayBuffer = (\n /** The buffer to be converted */\n buffer: ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n const unPadded = [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert a bigint to a hex string */\nexport const hexFromBigInt = (\n /** The bigint to be converted */\n value: bigint,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n): Hex => {\n const unPadded = value.toString(16)\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\n\n/**\n * Converts a number to a hex string by converting to BigInt first.\n * @param value - The number to convert\n * @param config - Optional hex output configuration\n * @returns The hex string representation\n */\nexport const hexFromNumber = (value: number, config?: HexConfig): Hex => {\n return hexFromBigInt(BigInt(value), config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromArrayBuffer } from './fromArrayBuffer.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\nimport { hexFromHexString } from './fromHexString.ts'\nimport { hexFromNumber } from './fromNumber.ts'\n\n/** Takes unknown value and tries our best to convert it to a hex string */\nexport const hexFrom = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n switch (typeof value) {\n case 'string': {\n return hexFromHexString(value, config)\n }\n case 'bigint': {\n return hexFromBigInt(value, config)\n }\n case 'number': {\n return hexFromNumber(value, config)\n }\n case 'object': {\n return hexFromArrayBuffer(value, config)\n }\n default: {\n throw new Error(`Invalid type: ${typeof value}`)\n }\n }\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { HexRegEx } from '../HexRegEx.ts'\n\n/** Branded type representing a validated lowercase hex string. */\nexport type BrandedHex = Brand<Lowercase<string>, { readonly __hex: true }>\n\n/** Zod schema that validates and transforms a string into a branded Hex type. */\nexport const HexZod = z.string().regex(HexRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHex)\n\n/** Configuration of validation and output format */\nexport interface HexConfig {\n bitLength?: number\n byteSize?: number\n prefix?: boolean\n}\n\n/** A validated hex string type, inferred from the HexZod schema. */\nexport type Hex = z.infer<typeof HexZod>\n","import { isString } from '@xylabs/typeof'\n\nimport { hexFromHexString } from './from/index.ts'\n\n/**\n * Checks whether a hex string represents a zero value.\n * @param value - The hex string to check\n * @returns True if zero, false if non-zero, or undefined if the input is not a string\n */\nexport const isHexZero = (value?: string) => {\n return isString(value) ? BigInt(hexFromHexString(value, { prefix: true })) === 0n : undefined\n}\n","/**\n * Converts an ArrayBuffer to a hex string without padding or normalization.\n * @param buffer - The ArrayBuffer to convert\n * @returns A lowercase hex string representation of the buffer\n */\nexport const toHexLegacy = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n}\n","import { hexFrom } from './from/index.ts'\nimport type { HexConfig } from './hex.ts'\n\n/** takes any value and tries our best to convert it to a hex string */\nexport const toHex = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n) => {\n const { prefix = false } = config\n return hexFrom(value, { prefix, ...config })\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isObject } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\nimport { isAddress } from './is.ts'\n\n/**\n * Attempts to coerce a value into an Address type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Address, or undefined if coercion fails and assert is not set\n */\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assert?: AssertConfig): Address | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: false })\n break\n }\n default: {\n return isObject(assert) ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n }\n return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n\n/** @alpha */\nexport function asAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressValidationZod.parse(value)\n : AddressValidationZod.safeParse(value).data\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { isHex } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\n/**\n * Type guard that checks whether a value is a valid 160-bit address.\n * @param value - The value to check\n * @param config - Optional hex config (defaults to 160-bit, no prefix)\n * @returns True if the value is a valid Address\n */\nexport const isAddress = (value: unknown, config: HexConfig = {}): value is Address => {\n const { bitLength = 160, prefix = false } = config\n return isHex(value, { bitLength, prefix })\n}\n\n/** @alpha */\nexport function isAddressV2(value: unknown): value is Address {\n return AddressValidationZod.safeParse(value).success\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { hexFrom } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressTransformZod } from './AddressTransformZod.ts'\n\n/**\n * Converts a value to a 160-bit Address hex string.\n * @param value - The value to convert (string, number, bigint, or ArrayBuffer)\n * @param config - Optional hex config (defaults to 160-bit, no prefix)\n * @returns The value as an Address\n */\nexport const toAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): Address => {\n const { bitLength = 160, prefix = false } = config\n return hexFrom(value, {\n bitLength, prefix, ...config,\n }) as unknown as Address\n}\n\n/** @alpha */\nexport function toAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressTransformZod.parse(value)\n : AddressTransformZod.safeParse(value).data\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { HexConfig } from './hex/index.ts'\nimport {\n hexFrom, hexFromHexString, isHex,\n} from './hex/index.ts'\nimport { HexRegExMinMaxMixedCaseWithPrefix } from './HexRegEx.ts'\n\n/** Regular expression matching a 20-byte Ethereum address with 0x prefix (mixed case). */\nexport const EthAddressRegEx = HexRegExMinMaxMixedCaseWithPrefix(20, 20)\n\n/** Zod schema that validates a string is a properly formatted Ethereum address. */\nexport const EthAddressToStringZod = z.string().regex(EthAddressRegEx)\n\n/** @deprecated use EthAddressToStringZod */\nexport const EthAddressToStringSchema = EthAddressToStringZod\n\n/** Zod schema that validates and transforms a string into an EthAddress type. */\nexport const EthAddressFromStringZod = z.string().regex(EthAddressRegEx).transform(v => toEthAddress(v))\n\n/** @deprecated use EthAddressFromStringZod */\nexport const EthAddressFromStringSchema = EthAddressFromStringZod\n\n/** Branded type representing a validated Ethereum address with 0x prefix. */\n// using true instead of unique symbol to avoid conflicts with other versions of library\nexport type EthAddress = Brand<string, { readonly __eth_address: true }>\n\n/** The zero Ethereum address constant (0x followed by 40 zero characters). */\nexport const ETH_ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' as EthAddress\n\n/**\n * Converts a value to a 0x-prefixed Ethereum address string.\n * @param value - The value to convert (string, number, bigint, or ArrayBuffer)\n * @param config - Optional hex config (defaults to 160-bit, no inner prefix)\n * @returns The value as an EthAddress\n */\nexport const toEthAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): EthAddress => {\n const { bitLength = 160, prefix = false } = config\n return `0x${hexFrom(value, {\n bitLength, prefix, ...config,\n })}` as EthAddress\n}\n\n/**\n * Type guard that checks whether a value is a valid 0x-prefixed Ethereum address.\n * @param value - The value to check\n * @param config - Optional hex config (defaults to 160-bit with prefix)\n * @returns True if the value is a valid EthAddress\n */\nexport const isEthAddress = (value: unknown, config: HexConfig = {}): value is EthAddress => {\n const { bitLength = 160, prefix = true } = config\n const loweredValue = typeof value === 'string' ? value.toLowerCase() : value\n return isHex(loweredValue, { bitLength, prefix })\n}\n\n/** Zod schema that validates a string as a properly formatted Ethereum address using regex and type guard. */\nexport const EthAddressZod = z.string()\n .regex(EthAddressRegEx, { message: 'Invalid address format' })\n .refine(\n isEthAddress,\n )\n\n/**\n * Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as EthAddress, or undefined if coercion fails and assert is not set\n */\nexport function asEthAddress(value: unknown): EthAddress | undefined\nexport function asEthAddress(value: unknown, assert: AssertConfig): EthAddress\nexport function asEthAddress(value: unknown, assert?: AssertConfig): EthAddress | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: true, byteSize: 4 })\n break\n }\n default: {\n if (value !== undefined) {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n }\n return isEthAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an EthAddress [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isUndefined } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport { type Hash } from './hash.ts'\nimport { isHash } from './is.ts'\n\n/**\n * Attempts to coerce a value into a Hash type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Hash, or undefined if coercion fails and assert is not set\n */\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assert?: AssertConfig): Hash | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return isUndefined(assert) ? undefined : assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`)\n}\n","import { isHex } from '../hex/index.ts'\nimport type { Hash, HashBitLength } from './hash.ts'\n\n/**\n * Type guard that checks whether a value is a valid hash of the specified bit length.\n * @param value - The value to check\n * @param bitLength - The expected bit length of the hash (defaults to 256)\n * @returns True if the value is a valid Hash\n */\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n return isHex(value, { bitLength })\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\n/** The byte length of a standard hash (32 bytes / 256 bits). */\nexport const HASH_LENGTH = 32 as const\n\n/** Regular expression matching a 32-byte (64 hex character) hash string. */\nexport const HashRegEx = HexRegExMinMax(HASH_LENGTH, HASH_LENGTH)\n\n/** A 256-bit zero hash constant. */\nexport const ZERO_HASH = '0000000000000000000000000000000000000000000000000000000000000000' as Hash\n\n/** Valid bit lengths for hash values. */\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\n/** Array of all valid hash bit lengths for runtime validation. */\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\n/**\n * Type guard that checks whether a value is a valid hash bit length.\n * @param value - The value to check\n * @returns True if the value is one of the supported HashBitLength values\n */\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\n/** Branded type representing a validated hash hex string. */\nexport type BrandedHash = Brand<Hex, { readonly __hash: true }>\n\n/** Zod schema that validates and transforms a string into a branded Hash type. */\nexport const HashZod = z.string()\n .regex(HashRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHash)\n\n/** A validated hash string type, inferred from the HashZod schema. */\nexport type Hash = z.infer<typeof HashZod>\n","import * as z from 'zod'\n\nimport { asHash } from './as.ts'\nimport type { Hash } from './hash.ts'\nimport { HashZod } from './hash.ts'\n\n/** Zod schema that transforms a Hash to a plain string for JSON serialization. */\nexport const HashToJsonZod = HashZod.transform<string>(v => v)\n/** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */\nexport const JsonToHashZod = z.string().transform<Hash>(v => asHash(v, true))\n","import { type Hex, hexFromHexString } from './hex/index.ts'\n\n/**\n * Converts a Hex string to a BigInt.\n * @param hex - The hex string to convert\n * @returns The BigInt representation of the hex value\n */\nexport function hexToBigInt(hex: Hex): bigint {\n return BigInt(hexFromHexString(hex, { prefix: true }))\n}\n","import * as z from 'zod'\n\nimport { toHex } from './hex/index.ts'\nimport { hexToBigInt } from './hexToBigInt.ts'\n\n/** Zod schema that transforms a non-negative BigInt into a hex string for JSON serialization. */\nexport const BigIntToJsonZod = z.bigint().nonnegative().transform(x => toHex(x))\n/** Zod schema that parses a JSON hex string into a BigInt. */\nexport const JsonToBigIntZod = z.string().transform(x => toHex(x)).transform(x => hexToBigInt(x))\n"],"mappings":";AACA,YAAY,OAAO;;;ACKZ,IAAM,iBAAiB,CAAC,WAAW,GAAG,WAAoB,OAAO,mBAAmB,MAAO;AAChG,SAAO,IAAI,OAAO,aAAa,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI;AACjE;AAQO,IAAM,oCAAoC,CAAC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BAAgB,QAAQ,UAAkB,OAAK,CAAC;AAEtD,IAAM,gBAAkB,UAAO,EAAE,UAAgB,OAAK,OAAO,GAAG,IAAI,CAAC;;;ACFrE,SAAS,YAAY,KAAkB;AAC5C,SAAO,OAAO,iBAAiB,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC;AACvD;;;ACTA,YAAYC,QAAO;AAMZ,IAAM,kBAAoB,UAAO,EAAE,YAAY,EAAE,UAAU,OAAK,MAAM,CAAC,CAAC;AAExE,IAAM,kBAAoB,UAAO,EAAE,UAAU,OAAK,MAAM,CAAC,CAAC,EAAE,UAAU,OAAK,YAAY,CAAC,CAAC;","names":["z","z","z","assertError","assertError","assertError","z","assertError","assertError","assertError","z","z","z"]}
1
+ {"version":3,"sources":["../../src/address/address.ts","../../src/HexRegEx.ts","../../src/address/AddressTransformZod.ts","../../src/address/AddressValidationZod.ts","../../src/hex/as.ts","../../src/hex/from/fromHexString.ts","../../src/hex/nibble.ts","../../src/hex/is.ts","../../src/hex/from/fromArrayBuffer.ts","../../src/hex/from/fromBigInt.ts","../../src/hex/from/fromNumber.ts","../../src/hex/from/from.ts","../../src/hex/hex.ts","../../src/hex/isHexZero.ts","../../src/hex/legacy.ts","../../src/hex/to.ts","../../src/address/as.ts","../../src/address/is.ts","../../src/address/to.ts","../../src/ethAddress.ts","../../src/hash/as.ts","../../src/hash/is.ts","../../src/hash/hash.ts","../../src/hash/zod.ts","../../src/hexToBigInt.ts","../../src/zod.ts"],"sourcesContent":["import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { type Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\n/** A 160-bit zero address constant. */\nexport const ZERO_ADDRESS = '0000000000000000000000000000000000000000' as Address\n/** The character length of an address hex string (40 hex characters / 20 bytes). */\nexport const ADDRESS_LENGTH = 40 as const\n\n/** Regular expression matching a 20-byte (40 hex character) address string. */\nexport const AddressRegEx = HexRegExMinMax(ADDRESS_LENGTH / 2, ADDRESS_LENGTH / 2)\n\ntype BrandedAddress = Brand<Hex, { readonly __address: true }>\n\n/** Zod schema that validates and transforms a string into a branded Address type. */\nexport const AddressZod = z.string().regex(AddressRegEx).transform<BrandedAddress>(v => v as BrandedAddress)\n\n/** A validated 20-byte address string type, inferred from the AddressZod schema. */\nexport type Address = z.infer<typeof AddressZod>\n","/**\n * Creates a RegExp matching lowercase hex strings with a byte length in the given range.\n * @param minBytes - Minimum number of bytes (default 0)\n * @param maxBytes - Maximum number of bytes\n * @returns A RegExp for validating hex strings within the byte range\n */\nexport const HexRegExMinMax = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^[a-f0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\n/**\n * Creates a RegExp matching mixed-case hex strings with a 0x prefix and a byte length in the given range.\n * @param minBytes - Minimum number of bytes (default 0)\n * @param maxBytes - Maximum number of bytes\n * @returns A RegExp for validating prefixed hex strings within the byte range\n */\nexport const HexRegExMinMaxMixedCaseWithPrefix = (minBytes = 0, maxBytes: number = (Number.MAX_SAFE_INTEGER / 2)) => {\n return new RegExp(`^0x[a-fA-F0-9]{${minBytes * 2},${maxBytes * 2}}$`)\n}\n\n/** Regular expression matching a lowercase hex string without prefix. */\nexport const HexRegEx = /^[0-9a-f]+$/\n/** Regular expression matching a lowercase hex string with a 0x prefix. */\nexport const HexRegExWithPrefix = /^0x[0-9a-f]+$/\n","import * as z from 'zod'\n\nimport { type Address, ADDRESS_LENGTH } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\n/** Zod schema that accepts a string, bigint, or number and transforms it into a validated Address. */\nexport const AddressTransformZod = z.union([z.string(), z.bigint(), z.number()])\n .transform((value) => {\n switch (typeof value) {\n case 'bigint': {\n return value.toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n case 'string': {\n if (value.startsWith('0x')) {\n return value.slice(2)\n }\n return value\n }\n case 'number': {\n return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n }\n })\n .refine(x => AddressValidationZod.safeParse(x).data)\n .transform(x => x as Address)\n\n/** The output type of AddressTransformZod after parsing and transformation. */\nexport type AddressTransformZodType = z.infer<typeof AddressTransformZod>\n","import * as z from 'zod'\n\nimport { HexZod } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { ADDRESS_LENGTH } from './address.ts'\n\n/** Zod schema that validates a string is a properly formatted 40-character hex address. */\nexport const AddressValidationZod = z.string()\n .refine(x => HexZod.safeParse(x).success)\n .refine(x => x.length === ADDRESS_LENGTH, { error: e => new Error(`Address must have 40 characters [${e.input}]`) })\n .transform(v => v as Address)\n\n/** The output type of AddressValidationZod after parsing. */\nexport type AddressValidationZodType = z.infer<typeof AddressValidationZod>\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\n\nimport { hexFromHexString } from './from/index.ts'\nimport type { Hex } from './hex.ts'\nimport { isHex } from './is.ts'\n\n/**\n * Attempts to coerce a value into a Hex type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Hex, or undefined if coercion fails and assert is not set\n */\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, assert?: AssertConfig): Hex | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n\n return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`)\n}\n","import { isNumber } from '@xylabs/typeof'\n\nimport type { Hex, HexConfig } from '../hex.ts'\nimport { isHex } from '../is.ts'\nimport { bitsToNibbles } from '../nibble.ts'\n\n/**\n * Normalizes a hex string by stripping an optional 0x prefix, lowercasing, and padding to byte/bit boundaries.\n * @param value - The hex string to normalize (with or without 0x prefix)\n * @param config - Configuration for prefix, byteSize, and bitLength padding\n * @returns The normalized Hex string\n */\nexport const hexFromHexString = (value: string, config: HexConfig = {}): Hex => {\n const {\n prefix = false, byteSize = 8, bitLength,\n } = config\n const nibbleBoundary = bitsToNibbles(byteSize)\n const unEvened = (value.startsWith('0x') ? value.slice(2) : value).toLowerCase()\n if (isHex(unEvened)) {\n const evenCharacters = unEvened.padStart(Math.ceil(unEvened.length / nibbleBoundary) * nibbleBoundary, '0')\n const padded = isNumber(bitLength) ? evenCharacters.padStart(bitLength / 4, '0') : evenCharacters\n return (prefix ? `0x${padded}` : padded).toLowerCase() as Hex\n } else {\n throw new Error('Received string is not a value hex')\n }\n}\n","/**\n * Converts a bit count to the equivalent number of hex nibbles (4 bits each).\n * @param value - The number of bits (must be a multiple of 4)\n * @returns The number of nibbles\n */\nexport const bitsToNibbles = (value: number): number => {\n const nibbles = value >> 2\n if (value !== nibbles << 2) throw new Error('Bits for nibbles must multiple of 4')\n return nibbles\n}\n\n/**\n * Converts a nibble count to the equivalent number of bits.\n * @param value - The number of nibbles\n * @returns The number of bits\n */\nexport const nibblesToBits = (value: number): number => {\n return value << 2\n}\n","import { HexRegEx, HexRegExWithPrefix } from '../HexRegEx.ts'\nimport type { Hex, HexConfig } from './hex.ts'\nimport { bitsToNibbles } from './nibble.ts'\n\n/**\n * Type guard that checks whether a value is a valid hex string.\n * @param value - The value to check\n * @param config - Optional configuration for prefix and bit length validation\n * @returns True if the value is a valid Hex string\n */\nexport const isHex = (value: unknown, config?: HexConfig): value is Hex => {\n // Is it a string?\n if (typeof value !== 'string') return false\n\n const valueCharLength = config?.prefix ? value.length - 2 : value.length\n\n // If a bitLength specified, does it conform?\n if (config?.bitLength !== undefined && valueCharLength !== bitsToNibbles(config?.bitLength)) return false\n\n // Does it only has hex values?\n return config?.prefix ? HexRegExWithPrefix.test(value) : HexRegEx.test(value)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert an ArrayBuffer to a hex string */\nexport const hexFromArrayBuffer = (\n /** The buffer to be converted */\n buffer: ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n const unPadded = [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromHexString } from './fromHexString.ts'\n\n/** Convert a bigint to a hex string */\nexport const hexFromBigInt = (\n /** The bigint to be converted */\n value: bigint,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n): Hex => {\n const unPadded = value.toString(16)\n return hexFromHexString(unPadded, config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\n\n/**\n * Converts a number to a hex string by converting to BigInt first.\n * @param value - The number to convert\n * @param config - Optional hex output configuration\n * @returns The hex string representation\n */\nexport const hexFromNumber = (value: number, config?: HexConfig): Hex => {\n return hexFromBigInt(BigInt(value), config)\n}\n","import type { Hex, HexConfig } from '../hex.ts'\nimport { hexFromArrayBuffer } from './fromArrayBuffer.ts'\nimport { hexFromBigInt } from './fromBigInt.ts'\nimport { hexFromHexString } from './fromHexString.ts'\nimport { hexFromNumber } from './fromNumber.ts'\n\n/** Takes unknown value and tries our best to convert it to a hex string */\nexport const hexFrom = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config?: HexConfig,\n): Hex => {\n switch (typeof value) {\n case 'string': {\n return hexFromHexString(value, config)\n }\n case 'bigint': {\n return hexFromBigInt(value, config)\n }\n case 'number': {\n return hexFromNumber(value, config)\n }\n case 'object': {\n return hexFromArrayBuffer(value, config)\n }\n default: {\n throw new Error(`Invalid type: ${typeof value}`)\n }\n }\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport { HexRegEx } from '../HexRegEx.ts'\n\n/** Branded type representing a validated lowercase hex string. */\nexport type BrandedHex = Brand<Lowercase<string>, { readonly __hex: true }>\n\n/** Zod schema that validates and transforms a string into a branded Hex type. */\nexport const HexZod = z.string().regex(HexRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHex)\n\n/** Configuration of validation and output format */\nexport interface HexConfig {\n bitLength?: number\n byteSize?: number\n prefix?: boolean\n}\n\n/** A validated hex string type, inferred from the HexZod schema. */\nexport type Hex = z.infer<typeof HexZod>\n","import { isString } from '@xylabs/typeof'\n\nimport { hexFromHexString } from './from/index.ts'\n\n/**\n * Checks whether a hex string represents a zero value.\n * @param value - The hex string to check\n * @returns True if zero, false if non-zero, or undefined if the input is not a string\n */\nexport const isHexZero = (value?: string) => {\n return isString(value) ? BigInt(hexFromHexString(value, { prefix: true })) === 0n : undefined\n}\n","/**\n * Converts an ArrayBuffer to a hex string without padding or normalization.\n * @param buffer - The ArrayBuffer to convert\n * @returns A lowercase hex string representation of the buffer\n */\nexport const toHexLegacy = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map(x => x.toString(16).padStart(2, '0')).join('')\n}\n","import { hexFrom } from './from/index.ts'\nimport type { HexConfig } from './hex.ts'\n\n/** takes any value and tries our best to convert it to a hex string */\nexport const toHex = (\n /** Supported types are string, number, bigint, and ArrayBuffer */\n value: string | number | bigint | ArrayBufferLike,\n /** Configuration of output format and validation */\n config: HexConfig = {},\n) => {\n const { prefix = false } = config\n return hexFrom(value, { prefix, ...config })\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isObject } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\nimport { isAddress } from './is.ts'\n\n/**\n * Attempts to coerce a value into an Address type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Address, or undefined if coercion fails and assert is not set\n */\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assert?: AssertConfig): Address | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: false, byteSize: 4 })\n break\n }\n default: {\n return isObject(assert) ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n }\n return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n\n/** @alpha */\nexport function asAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressValidationZod.parse(value)\n : AddressValidationZod.safeParse(value).data\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { isHex } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressValidationZod } from './AddressValidationZod.ts'\n\n/**\n * Type guard that checks whether a value is a valid 160-bit address.\n * @param value - The value to check\n * @param config - Optional hex config (defaults to 160-bit, no prefix)\n * @returns True if the value is a valid Address\n */\nexport const isAddress = (value?: unknown, config: HexConfig = {}): value is Address => {\n const { bitLength = 160, prefix = false } = config\n return isHex(value, { bitLength, prefix })\n}\n\n/** @alpha */\nexport function isAddressV2(value?: unknown): value is Address {\n return AddressValidationZod.safeParse(value).success\n}\n","import type { HexConfig } from '../hex/index.ts'\nimport { hexFrom } from '../hex/index.ts'\nimport type { Address } from './address.ts'\nimport { AddressTransformZod } from './AddressTransformZod.ts'\n\n/**\n * Converts a value to a 160-bit Address hex string.\n * @param value - The value to convert (string, number, bigint, or ArrayBuffer)\n * @param config - Optional hex config (defaults to 160-bit, no prefix)\n * @returns The value as an Address\n */\nexport const toAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): Address => {\n const { bitLength = 160, prefix = false } = config\n return hexFrom(value, {\n bitLength, prefix, ...config,\n }) as unknown as Address\n}\n\n/** @alpha */\nexport function toAddressV2(value: unknown, assert: boolean = false): Address | undefined {\n return assert\n ? AddressTransformZod.parse(value)\n : AddressTransformZod.safeParse(value).data\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { HexConfig } from './hex/index.ts'\nimport {\n hexFrom, hexFromHexString, isHex,\n} from './hex/index.ts'\nimport { HexRegExMinMaxMixedCaseWithPrefix } from './HexRegEx.ts'\n\n/** Regular expression matching a 20-byte Ethereum address with 0x prefix (mixed case). */\nexport const EthAddressRegEx = HexRegExMinMaxMixedCaseWithPrefix(20, 20)\n\n/** Zod schema that validates a string is a properly formatted Ethereum address. */\nexport const EthAddressToStringZod = z.string().regex(EthAddressRegEx)\n\n/** @deprecated use EthAddressToStringZod */\nexport const EthAddressToStringSchema = EthAddressToStringZod\n\n/** Zod schema that validates and transforms a string into an EthAddress type. */\nexport const EthAddressFromStringZod = z.string().regex(EthAddressRegEx).transform(v => toEthAddress(v))\n\n/** @deprecated use EthAddressFromStringZod */\nexport const EthAddressFromStringSchema = EthAddressFromStringZod\n\n/** Branded type representing a validated Ethereum address with 0x prefix. */\n// using true instead of unique symbol to avoid conflicts with other versions of library\nexport type EthAddress = Brand<string, { readonly __eth_address: true }>\n\n/** The zero Ethereum address constant (0x followed by 40 zero characters). */\nexport const ETH_ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' as EthAddress\n\n/**\n * Converts a value to a 0x-prefixed Ethereum address string.\n * @param value - The value to convert (string, number, bigint, or ArrayBuffer)\n * @param config - Optional hex config (defaults to 160-bit, no inner prefix)\n * @returns The value as an EthAddress\n */\nexport const toEthAddress = (value: string | number | bigint | ArrayBufferLike, config: HexConfig = {}): EthAddress => {\n const { bitLength = 160, prefix = false } = config\n return `0x${hexFrom(value, {\n bitLength, prefix, ...config,\n })}` as EthAddress\n}\n\n/**\n * Type guard that checks whether a value is a valid 0x-prefixed Ethereum address.\n * @param value - The value to check\n * @param config - Optional hex config (defaults to 160-bit with prefix)\n * @returns True if the value is a valid EthAddress\n */\nexport const isEthAddress = (value: unknown, config: HexConfig = {}): value is EthAddress => {\n const { bitLength = 160, prefix = true } = config\n const loweredValue = typeof value === 'string' ? value.toLowerCase() : value\n return isHex(loweredValue, { bitLength, prefix })\n}\n\n/** Zod schema that validates a string as a properly formatted Ethereum address using regex and type guard. */\nexport const EthAddressZod = z.string()\n .regex(EthAddressRegEx, { message: 'Invalid address format' })\n .refine(\n isEthAddress,\n )\n\n/**\n * Attempts to coerce a value into an EthAddress, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as EthAddress, or undefined if coercion fails and assert is not set\n */\nexport function asEthAddress(value: unknown): EthAddress | undefined\nexport function asEthAddress(value: unknown, assert: AssertConfig): EthAddress\nexport function asEthAddress(value: unknown, assert?: AssertConfig): EthAddress | undefined {\n try {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value, { prefix: true, byteSize: 4 })\n break\n }\n default: {\n if (value !== undefined) {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n }\n return isEthAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an EthAddress [${value}]`)\n } catch (ex) {\n const error = ex as Error\n return assertError(undefined, assert, error.message)\n }\n}\n","import type { AssertConfig } from '@xylabs/error'\nimport { assertError } from '@xylabs/error'\nimport { isUndefined } from '@xylabs/typeof'\n\nimport { hexFromHexString } from '../hex/index.ts'\nimport { type Hash } from './hash.ts'\nimport { isHash } from './is.ts'\n\n/**\n * Attempts to coerce a value into a Hash type, returning undefined or throwing based on the assert config.\n * @param value - The value to coerce (must be a string)\n * @param assert - If provided, throws on failure instead of returning undefined\n * @returns The value as Hash, or undefined if coercion fails and assert is not set\n */\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assert?: AssertConfig): Hash | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string': {\n stringValue = hexFromHexString(value)\n break\n }\n default: {\n return isUndefined(assert) ? undefined : assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\n return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`)\n}\n","import { isHex } from '../hex/index.ts'\nimport type { Hash, HashBitLength } from './hash.ts'\n\n/**\n * Type guard that checks whether a value is a valid hash of the specified bit length.\n * @param value - The value to check\n * @param bitLength - The expected bit length of the hash (defaults to 256)\n * @returns True if the value is a valid Hash\n */\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n return isHex(value, { bitLength })\n}\n","import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod'\n\nimport type { Hex } from '../hex/index.ts'\nimport { HexRegExMinMax } from '../HexRegEx.ts'\n\n/** The byte length of a standard hash (32 bytes / 256 bits). */\nexport const HASH_LENGTH = 32 as const\n\n/** Regular expression matching a 32-byte (64 hex character) hash string. */\nexport const HashRegEx = HexRegExMinMax(HASH_LENGTH, HASH_LENGTH)\n\n/** A 256-bit zero hash constant. */\nexport const ZERO_HASH = '0000000000000000000000000000000000000000000000000000000000000000' as Hash\n\n/** Valid bit lengths for hash values. */\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\n/** Array of all valid hash bit lengths for runtime validation. */\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\n/**\n * Type guard that checks whether a value is a valid hash bit length.\n * @param value - The value to check\n * @returns True if the value is one of the supported HashBitLength values\n */\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\n/** Branded type representing a validated hash hex string. */\nexport type BrandedHash = Brand<Hex, { readonly __hash: true }>\n\n/** Zod schema that validates and transforms a string into a branded Hash type. */\nexport const HashZod = z.string()\n .regex(HashRegEx, { message: 'Invalid hex format' }).transform(val => val as BrandedHash)\n\n/** A validated hash string type, inferred from the HashZod schema. */\nexport type Hash = z.infer<typeof HashZod>\n","import * as z from 'zod'\n\nimport { asHash } from './as.ts'\nimport type { Hash } from './hash.ts'\nimport { HashZod } from './hash.ts'\n\n/** Zod schema that transforms a Hash to a plain string for JSON serialization. */\nexport const HashToJsonZod = HashZod.transform<string>(v => v)\n/** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */\nexport const JsonToHashZod = z.string().transform<Hash>(v => asHash(v, true))\n","import { type Hex, hexFromHexString } from './hex/index.ts'\n\n/**\n * Converts a Hex string to a BigInt.\n * @param hex - The hex string to convert\n * @returns The BigInt representation of the hex value\n */\nexport function hexToBigInt(hex: Hex): bigint {\n return BigInt(hexFromHexString(hex, { prefix: true }))\n}\n","import * as z from 'zod'\n\nimport { toHex } from './hex/index.ts'\nimport { hexToBigInt } from './hexToBigInt.ts'\n\n/** Zod schema that transforms a non-negative BigInt into a hex string for JSON serialization. */\nexport const BigIntToJsonZod = z.bigint().nonnegative().transform(x => toHex(x))\n/** Zod schema that parses a JSON hex string into a BigInt. */\nexport const JsonToBigIntZod = z.string().transform(x => toHex(x)).transform(x => hexToBigInt(x))\n"],"mappings":";AACA,YAAY,OAAO;;;ACKZ,IAAM,iBAAiB,CAAC,WAAW,GAAG,WAAoB,OAAO,mBAAmB,MAAO;AAChG,SAAO,IAAI,OAAO,aAAa,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI;AACjE;AAQO,IAAM,oCAAoC,CAAC,WAAW,GAAG,WAAoB,OAAO,mBAAmB,MAAO;AACnH,SAAO,IAAI,OAAO,kBAAkB,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI;AACtE;AAGO,IAAM,WAAW;AAEjB,IAAM,qBAAqB;;;ADhB3B,IAAM,eAAe;AAErB,IAAM,iBAAiB;AAGvB,IAAM,eAAe,eAAe,iBAAiB,GAAG,iBAAiB,CAAC;AAK1E,IAAM,aAAe,SAAO,EAAE,MAAM,YAAY,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AAK,MAAM,CAAC,CAAC;AAExE,IAAM,kBAAoB,UAAO,EAAE,UAAU,OAAK,MAAM,CAAC,CAAC,EAAE,UAAU,OAAK,YAAY,CAAC,CAAC;","names":["z","z","z","assertError","assertError","assertError","z","assertError","assertError","assertError","z","z","z"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/hex",
3
- "version": "5.0.84",
3
+ "version": "5.0.86",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "hex",
@@ -42,13 +42,13 @@
42
42
  "!**/*.test.*"
43
43
  ],
44
44
  "dependencies": {
45
- "@xylabs/error": "~5.0.84",
46
- "@xylabs/typeof": "~5.0.84"
45
+ "@xylabs/error": "~5.0.86",
46
+ "@xylabs/typeof": "~5.0.86"
47
47
  },
48
48
  "devDependencies": {
49
- "@xylabs/ts-scripts-yarn3": "~7.4.13",
50
- "@xylabs/tsconfig": "~7.4.13",
51
- "@xylabs/vitest-extended": "~5.0.84",
49
+ "@xylabs/ts-scripts-yarn3": "~7.4.16",
50
+ "@xylabs/tsconfig": "~7.4.16",
51
+ "@xylabs/vitest-extended": "~5.0.86",
52
52
  "typescript": "~5.9.3",
53
53
  "vitest": "~4.0.18",
54
54
  "zod": "^4.3.6"