UNPKG

@xylabs/hex

Version:

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

28 lines 1.38 kB
import type { Brand } from '@xylabs/typeof'; import * as z from 'zod'; import type { Hex } from '../hex/index.ts'; /** The byte length of a standard hash (32 bytes / 256 bits). */ export declare const HASH_LENGTH: 32; /** Regular expression matching a 32-byte (64 hex character) hash string. */ export declare const HashRegEx: RegExp; /** A 256-bit zero hash constant. */ export declare const ZERO_HASH: Hash; /** Valid bit lengths for hash values. */ export type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096; /** Array of all valid hash bit lengths for runtime validation. */ export declare const HashBitLength: HashBitLength[]; /** * Type guard that checks whether a value is a valid hash bit length. * @param value - The value to check * @returns True if the value is one of the supported HashBitLength values */ export declare const isHashBitLength: (value: unknown) => value is HashBitLength; /** Branded type representing a validated hash hex string. */ export type BrandedHash = Brand<Hex, { readonly __hash: true; }>; /** Zod schema that validates and transforms a string into a branded Hash type. */ export declare const HashZod: z.ZodPipe<z.ZodString, z.ZodTransform<BrandedHash, string>>; /** A validated hash string type, inferred from the HashZod schema. */ export type Hash = z.infer<typeof HashZod>; //# sourceMappingURL=hash.d.ts.map