import type { Guard } from "./Guard"; /* * ------------------------------------------- * Guard Methods * ------------------------------------------- */ export const alt_ = (me: Guard, that: () => Guard): Guard => ({ is: (i): i is A => me.is(i) || that().is(i) }); export const alt = (that: () => Guard) => (me: Guard): Guard => alt_(me, that); export const zero = (): Guard => ({ is: (_): _ is A => false }); export const compose_ = (from: Guard, to: Guard): Guard => ({ is: (i): i is B => from.is(i) && to.is(i) }); export const compose = (to: Guard) => (from: Guard): Guard => compose_(from, to); export const id = (): Guard => ({ is: (_): _ is A => true });