import { Func, isFunc } from './Func'; export type Get = Func | T; export type Predicate = Get; export const ofGet = (g: Get, ...args: Args[]): T => (isFunc(g) ? g(...args) : g); export const ifGet = (pred: Get, valid: Get, invalid: Get): T => (ofGet(pred) ? ofGet(valid) : ofGet(invalid)); export type GetProperty = keyof T | Func; export const ofProperty = (t: T, p: GetProperty): Prop => (isFunc(p) ? p(t) : ((t as any)[p] as Prop));