Brand
Brand:
object
Defined in: Types/Brand.ts:25
Type Declaration
Section titled “Type Declaration”unwrap
Section titled “unwrap”unwrap: <
K,T>(branded) =>T
Strips the brand and returns the underlying value. Since Brand<K, T> extends T this is rarely needed, but can improve readability.
Type Parameters
Section titled “Type Parameters”K extends string
T
Parameters
Section titled “Parameters”branded
Section titled “branded”Brand<K, T>
Returns
Section titled “Returns”T
Example
Section titled “Example”wrap: <
K,T>() => (value) =>Brand<K,T>
Returns a constructor that wraps a value of type T in brand K. The resulting function performs an unchecked cast — only use when the raw value is known to satisfy the brand’s invariants.
Type Parameters
Section titled “Type Parameters”K extends string
T
Returns
Section titled “Returns”(value) => Brand<K, T>