@typed/io
Version:
Runtime IO type system
9 lines (6 loc) • 347 B
text/typescript
import { isArray } from '@typed/logic'
import { Guard, TypeOf } from './Guard'
import { refinement } from './refinement'
export const Array: Guard<ReadonlyArray<unknown>> = Guard.is(isArray)
export const array = <G extends Guard>(g: G): Guard<ReadonlyArray<TypeOf<G>>> =>
refinement(Array, (u): u is ReadonlyArray<TypeOf<G>> => u.every(g.is))