Hyperlinkv0.8.0-beta.28

Brand

Brand.nominalfunctioneffect/Brand.ts:228
<A extends Brand<any>>(): Constructor<A>

Returns a Constructor that does not apply any runtime checks and just returns the provided value.

When to use

Use to create nominal types that allow distinguishing between two values of the same type but with different meanings.

constructorsmakecheck
Source effect/Brand.ts:2287 lines
export function nominal<A extends Brand<any>>(): Constructor<A> {
  return Object.assign((input: Brand.Unbranded<A>) => input as A, {
    option: (input: Brand.Unbranded<A>) => Option.some(input as A),
    result: (input: Brand.Unbranded<A>) => Result.succeed(input as A),
    is: (_: Brand.Unbranded<A>): _ is Brand.Unbranded<A> & A => true
  })
}
Referenced by 2 symbols