@thisisagile/easy
Version:
Straightforward library for building domain-driven microservice architectures
8 lines (7 loc) • 457 B
TypeScript
import { Func } from './Func';
export type Get<T = any, Args = any> = Func<T, Args> | T;
export type Predicate<Args = unknown> = Get<boolean, Args>;
export declare const ofGet: <T, Args = any>(g: Get<T, Args>, ...args: Args[]) => T;
export declare const ifGet: <T>(pred: Get, valid: Get<T>, invalid: Get<T>) => T;
export type GetProperty<T, Prop> = keyof T | Func<Prop, T>;
export declare const ofProperty: <T, Prop>(t: T, p: GetProperty<T, Prop>) => Prop;