UNPKG

@typed/io

Version:

Runtime IO type system

8 lines (5 loc) 259 B
import * as G from '../guard' import { Decoder, TypeOf } from './Decoder' import { union } from './Union' export const Null = Decoder.fromGuard(G.Null, `null`) export const nullable = <A extends Decoder>(d: A): Decoder<TypeOf<A> | null> => union([d, Null])