//#region src/branded/Brand.d.ts type Brand = T & { readonly __brand: K; }; type Unwrap = T extends Brand ? U : T; type ExtractBrand = T extends Brand ? K : never; /** * Brand is a utility for creating nominal typing in TypeScript. * It creates phantom types that exist only at compile time. * At runtime, the branded value IS the primitive value. * * @param _brand * @param value - The value to brand * @returns The value with phantom type brand */ declare function Brand(_brand: K, value: T): Brand; /** * Helper to unwrap a branded value to its underlying type * Works with both Brand and ValidatedBrand * @param branded - The branded value (can be null or undefined) * @returns The original value without the brand * * Note: Also exported as 'unwrap' from 'functype/branded' for convenience */ declare function unwrapBrand(branded: Brand): T; declare function unwrapBrand(branded: Brand | null): T | null; declare function unwrapBrand(branded: Brand | undefined): T | undefined; declare function unwrapBrand(branded: Brand | null | undefined): T | null | undefined; /** * Type guard for checking if a value has a specific brand * @param value - The value to check * @param _brand - The brand to check for (unused at runtime) * @returns True if the value has the specified brand * * Note: Since brands are phantom types that exist only at compile time, * this function can only provide a runtime approximation. It always returns true * for non-null values, as we have no way to actually check the brand at runtime. * This function is primarily for API consistency and documentation purposes. */ declare function hasBrand(value: unknown, _brand: K): value is Brand; /** * Create a branded type constructor for a specific brand * @param brand - The brand name * @returns A function that brands values with the specified brand */ declare function createBrander(brand: K): (value: T) => Brand; type BrandedString = Brand; type BrandedNumber = Brand; type BrandedBoolean = Brand; declare const BrandedString: (brand: K) => (value: string) => BrandedString; declare const BrandedNumber: (brand: K) => (value: number) => BrandedNumber; declare const BrandedBoolean: (brand: K) => (value: boolean) => BrandedBoolean; //#endregion export { ExtractBrand as a, hasBrand as c, BrandedString as i, unwrapBrand as l, BrandedBoolean as n, Unwrap as o, BrandedNumber as r, createBrander as s, Brand as t };