@typed/io
Version:
Runtime IO type system
9 lines (6 loc) • 319 B
text/typescript
import { isSet } from '@typed/logic'
import { Guard, TypeOf } from './Guard'
import { refinement } from './refinement'
export const Set: Guard<ReadonlySet<unknown>> = { is: isSet }
export const set = <A extends Guard>(g: A) =>
refinement(Set, (s): s is ReadonlySet<TypeOf<A>> => Array.from(s.values()).every(g.is))