functype 0.8.84 → 0.9.0

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.
@@ -1,2 +0,0 @@
1
- function e(n,r){return r}function t(n){return n}function d(n,r){return n!=null}function a(n){return r=>e(n,r)}var o=n=>r=>e(n,r),s=n=>r=>e(n,r),K=n=>r=>e(n,r);export{e as a,t as b,d as c,a as d,o as e,s as f,K as g};//# sourceMappingURL=chunk-TQJDL6YW.mjs.map
2
- //# sourceMappingURL=chunk-TQJDL6YW.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/branded/Brand.ts"],"names":["Brand","brand","value","unbrand","branded","hasBrand","createBrander","BrandedString","BrandedNumber","BrandedBoolean"],"mappings":"AAoBO,SAASA,CAAAA,CAA2BC,CAAAA,CAAUC,CAAAA,CAAuB,CAC1E,OAAOA,CACT,CAOO,SAASC,CAAAA,CAAWC,CAAAA,CAA8B,CACvD,OAAOA,CACT,CAaO,SAASC,CAAAA,CAA8BH,CAAAA,CAAgBD,CAAAA,CAAgC,CAG5F,OAAOC,CAAAA,EAAU,IACnB,CAOO,SAASI,CAAAA,CAAmCL,CAAAA,CAAU,CAC3D,OAAQC,CAAAA,EAA0BF,CAAAA,CAAMC,CAAAA,CAAOC,CAAK,CACtD,KAQaK,CAAAA,CACQN,CAAAA,EAClBC,CAAAA,EACCF,CAAAA,CAAMC,CAAAA,CAAOC,CAAK,EAETM,CAAAA,CACQP,CAAAA,EAClBC,CAAAA,EACCF,CAAAA,CAAMC,CAAAA,CAAOC,CAAK,CAAA,CAETO,CAAAA,CACQR,CAAAA,EAClBC,CAAAA,EACCF,CAAAA,CAAMC,CAAAA,CAAOC,CAAK","file":"chunk-TQJDL6YW.mjs","sourcesContent":["/**\n * Brand is a utility for creating nominal typing in TypeScript\n * It allows for creating distinct types that are structurally identical\n * but considered different by TypeScript's type system\n */\n\n// The brand symbol type\nexport type Brand<K extends string, T> = T & { readonly __brand: K }\n\n// Utility type to extract the underlying type from a branded type\nexport type Unbrand<T> = T extends Brand<string, infer U> ? U : never\n\n// Utility type to extract the brand from a branded type\nexport type ExtractBrand<T> = T extends Brand<infer K, unknown> ? K : never\n\n/**\n * Helper to create a branded type\n * @param value - The value to brand\n * @returns The branded value\n */\nexport function Brand<K extends string, T>(brand: K, value: T): Brand<K, T> {\n return value as Brand<K, T>\n}\n\n/**\n * Helper to remove a brand from a value\n * @param branded - The branded value\n * @returns The original value without the brand\n */\nexport function unbrand<T>(branded: Brand<string, T>): T {\n return branded as T\n}\n\n/**\n * Type guard for checking if a value has a specific brand\n * @param value - The value to check\n * @param brand - The brand to check for\n * @returns True if the value has the specified brand\n *\n * Note: Since brands are phantom types that exist only at compile time,\n * this function can only provide a runtime approximation. It always returns true\n * for non-null values, as we have no way to actually check the brand at runtime.\n * This function is primarily for API consistency and documentation purposes.\n */\nexport function hasBrand<K extends string, T>(value: unknown, brand: K): value is Brand<K, T> {\n // In a phantom type system, we can't actually check the brand at runtime\n // We can only verify the value exists\n return value !== null && value !== undefined\n}\n\n/**\n * Create a branded type constructor for a specific brand\n * @param brand - The brand name\n * @returns A function that brands values with the specified brand\n */\nexport function createBrander<K extends string, T>(brand: K) {\n return (value: T): Brand<K, T> => Brand(brand, value)\n}\n\n// Common branded primitive types\nexport type BrandedString<K extends string> = Brand<K, string>\nexport type BrandedNumber<K extends string> = Brand<K, number>\nexport type BrandedBoolean<K extends string> = Brand<K, boolean>\n\n// Factory for common primitive branded types\nexport const BrandedString =\n <K extends string>(brand: K) =>\n (value: string): BrandedString<K> =>\n Brand(brand, value)\n\nexport const BrandedNumber =\n <K extends string>(brand: K) =>\n (value: number): BrandedNumber<K> =>\n Brand(brand, value)\n\nexport const BrandedBoolean =\n <K extends string>(brand: K) =>\n (value: boolean): BrandedBoolean<K> =>\n Brand(brand, value)\n"]}