Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@xylabs/hex

Package Overview
Dependencies
Maintainers
5
Versions
448
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/hex - npm Package Compare versions

Comparing version
6.0.2
to
6.0.3
+5
-9
dist/neutral/index.mjs

@@ -111,7 +111,6 @@ // src/address/address.ts

function asHex(value, assert) {
let stringValue = void 0;
switch (typeof value) {
case "string": {
stringValue = hexFromHexString(value);
break;
const stringValue = hexFromHexString(value);
return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`);
}

@@ -122,3 +121,2 @@ default: {

}
return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`);
}

@@ -154,3 +152,3 @@

z3.refine((x) => HexZod.safeParse(x).success),
z3.refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${e.input}]`) })
z3.refine((x) => x.length === ADDRESS_LENGTH, { error: (e) => new Error(`Address must have 40 characters [${String(e.input)}]`) })
),

@@ -287,7 +285,6 @@ z3.transform((v) => v)

function asHash(value, assert) {
let stringValue = void 0;
switch (typeof value) {
case "string": {
stringValue = hexFromHexString(value);
break;
const stringValue = hexFromHexString(value);
return isHash(stringValue) ? stringValue : assertError4(value, assert, `Value is not a Hash [${value}]`);
}

@@ -298,3 +295,2 @@ default: {

}
return isHash(stringValue) ? stringValue : assertError4(value, assert, `Value is not a Hash [${value}]`);
}

@@ -301,0 +297,0 @@

{
"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/mini'\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.pipe(\n z.string().check(z.regex(AddressRegEx)),\n z.transform((v: string): BrandedAddress => v as BrandedAddress),\n)\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/mini'\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.pipe(\n z.pipe(\n z.union([z.string(), z.bigint(), z.number()]),\n z.transform((value: string | bigint | number): string => {\n if (typeof value === 'bigint') {\n return value.toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n if (typeof value === 'string') {\n return value.startsWith('0x') ? value.slice(2) : value\n }\n return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, '0')\n }),\n ).check(z.refine((x: string) => AddressValidationZod.safeParse(x).success)),\n z.transform((x: string): Address => x as Address),\n)\n\n/** The output type of AddressTransformZod after parsing and transformation. */\nexport type AddressTransformZodType = z.infer<typeof AddressTransformZod>\n", "import * as z from 'zod/mini'\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.pipe(\n z.string().check(\n z.refine((x: string) => HexZod.safeParse(x).success),\n z.refine((x: string) => x.length === ADDRESS_LENGTH, { error: e => new Error(`Address must have 40 characters [${e.input}]`) }),\n ),\n z.transform((v: string): Address => v as Address),\n)\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/mini'\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.pipe(\n z.string().check(z.regex(HexRegEx, { error: 'Invalid hex format' })),\n z.transform((val: string) => val as BrandedHex),\n)\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 = 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 = 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/mini'\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().check(z.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.pipe(\n z.string().check(z.regex(EthAddressRegEx)),\n z.transform((v: string) => toEthAddress(v)),\n)\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().check(\n z.regex(EthAddressRegEx, { error: 'Invalid address format' }),\n z.refine(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/mini'\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.pipe(\n z.string().check(z.regex(HashRegEx, { error: 'Invalid hex format' })),\n z.transform((val: string) => val as BrandedHash),\n)\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/mini'\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 = z.pipe(HashZod, z.transform((v: Hash): string => v))\n/** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */\nexport const JsonToHashZod = z.pipe(z.string(), z.transform((v: string): Hash => 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/mini'\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.pipe(\n z.bigint().check(z.nonnegative()),\n z.transform((x: bigint) => toHex(x)),\n)\n/** Zod schema that parses a JSON hex string into a BigInt. */\nexport const JsonToBigIntZod = z.pipe(\n z.string(),\n z.transform((x: string) => hexToBigInt(toHex(x))),\n)\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;AAAA,EACxB,SAAO,EAAE,MAAQ,QAAM,YAAY,CAAC;AAAA,EACpC,YAAU,CAAC,MAA8B,CAAmB;AAChE;;;AEpBA,YAAYA,QAAO;;;ACAnB,YAAYC,QAAO;;;ACCnB,SAAS,mBAAmB;;;ACD5B,SAAS,gBAAgB;;;ACKlB,IAAM,gBAAgB,CAAC,UAA0B;AACtD,QAAM,UAAU,SAAS;AACzB,MAAI,UAAU,WAAW,EAAG,OAAM,IAAI,MAAM,qCAAqC;AACjF,SAAO;AACT;AAOO,IAAM,gBAAgB,CAAC,UAA0B;AACtD,SAAO,SAAS;AAClB;;;ACRO,IAAM,QAAQ,CAAC,OA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IAAM,kBAAoB;AAAA,EAC7B,UAAO;AAAA,EACP,aAAU,CAAC,MAAc,YAAY,MAAM,CAAC,CAAC,CAAC;AAClD;",
"sourcesContent": ["import type { Brand } from '@xylabs/typeof'\nimport * as z from 'zod/mini'\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.pipe(\n z.string().check(z.regex(AddressRegEx)),\n z.transform((v: string): BrandedAddress => v as BrandedAddress),\n)\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/mini'\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.pipe(\n z.pipe(\n z.union([z.string(), z.bigint(), z.number()]),\n z.transform((value: string | bigint | number): string => {\n if (typeof value === 'bigint') {\n return value.toString(16).padStart(ADDRESS_LENGTH, '0')\n }\n if (typeof value === 'string') {\n return value.startsWith('0x') ? value.slice(2) : value\n }\n return BigInt(value).toString(16).padStart(ADDRESS_LENGTH, '0')\n }),\n ).check(z.refine((x: string) => AddressValidationZod.safeParse(x).success)),\n z.transform((x: string): Address => x as Address),\n)\n\n/** The output type of AddressTransformZod after parsing and transformation. */\nexport type AddressTransformZodType = z.infer<typeof AddressTransformZod>\n", "import * as z from 'zod/mini'\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.pipe(\n z.string().check(\n z.refine((x: string) => HexZod.safeParse(x).success),\n z.refine((x: string) => x.length === ADDRESS_LENGTH, { error: e => new Error(`Address must have 40 characters [${String(e.input)}]`) }),\n ),\n z.transform((v: string): Address => v as Address),\n)\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 switch (typeof value) {\n case 'string': {\n const stringValue = hexFromHexString(value)\n return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`)\n }\n default: {\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\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/mini'\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.pipe(\n z.string().check(z.regex(HexRegEx, { error: 'Invalid hex format' })),\n z.transform((val: string) => val as BrandedHex),\n)\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 = 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 = 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/mini'\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().check(z.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.pipe(\n z.string().check(z.regex(EthAddressRegEx)),\n z.transform((v: string) => toEthAddress(v)),\n)\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().check(\n z.regex(EthAddressRegEx, { error: 'Invalid address format' }),\n z.refine(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 switch (typeof value) {\n case 'string': {\n const stringValue = hexFromHexString(value)\n return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`)\n }\n default: {\n return isUndefined(assert) ? undefined : assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n }\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/mini'\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.pipe(\n z.string().check(z.regex(HashRegEx, { error: 'Invalid hex format' })),\n z.transform((val: string) => val as BrandedHash),\n)\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/mini'\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 = z.pipe(HashZod, z.transform((v: Hash): string => v))\n/** Zod schema that parses a JSON string into a validated Hash, throwing on invalid input. */\nexport const JsonToHashZod = z.pipe(z.string(), z.transform((v: string): Hash => 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/mini'\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.pipe(\n z.bigint().check(z.nonnegative()),\n z.transform((x: bigint) => toHex(x)),\n)\n/** Zod schema that parses a JSON hex string into a BigInt. */\nexport const JsonToBigIntZod = z.pipe(\n z.string(),\n z.transform((x: string) => hexToBigInt(toHex(x))),\n)\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;AAAA,EACxB,SAAO,EAAE,MAAQ,QAAM,YAAY,CAAC;AAAA,EACpC,YAAU,CAAC,MAA8B,CAAmB;AAChE;;;AEpBA,YAAYA,QAAO;;;ACAnB,YAAYC,QAAO;;;ACCnB,SAAS,mBAAmB;;;ACD5B,SAAS,gBAAgB;;;ACKlB,IAAM,gBAAgB,CAAC,UAA0B;AACtD,QAAM,UAAU,SAAS;AACzB,MAAI,UAAU,WAAW,EAAG,OAAM,IAAI,MAAM,qCAAqC;AACjF,SAAO;AACT;AAOO,IAAM,gBAAgB,CAAC,UAA0B;AACtD,SAAO,SAAS;AAClB;;;ACRO,IAAM,QAAQ,CAAC,OAAgB,WAAqC;AAEzE,MAAI,OAAO,UAAU,SAAU,QAAO;AAEtC,QAAM,kBAAkB,QAAQ,SAAS,MAAM,SAAS,IAAI,MAAM;AAGlE,MAAI,QAAQ,cAAc,UAAa,oBAAoB,cAAc,QAAQ,SAAS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6.0.2",
"version": "6.0.3",
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",

@@ -48,14 +48,14 @@ "keywords": [

"dependencies": {
"@xylabs/error": "~6.0.2",
"@xylabs/typeof": "~6.0.2"
"@xylabs/typeof": "~6.0.3",
"@xylabs/error": "~6.0.3"
},
"devDependencies": {
"@xylabs/toolchain": "^8.1.1",
"@xylabs/tsconfig": "^8.1.1",
"@xylabs/toolchain": "^8.1.4",
"@xylabs/tsconfig": "^8.1.4",
"eslint": "^10.4.0",
"typescript": "^6.0.3",
"vite": "^8.0.13",
"vite": "^8.0.14",
"vitest": "^4.1.7",
"zod": "^4.4.3",
"@xylabs/vitest-extended": "~6.0.2"
"@xylabs/vitest-extended": "~6.0.3"
},

@@ -62,0 +62,0 @@ "peerDependencies": {