UNPKG

@thisisagile/easy

Version:

Straightforward library for building domain-driven microservice architectures

110 lines (109 loc) • 6.3 kB
import { Get, Predicate } from './Get'; import { TypeGuard } from './TypeGuard'; import { Func } from './Func'; declare class CaseBuilder<V> { readonly v: V; is: { true: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: <T>(prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <T, U = unknown>(guard: TypeGuard<U>, out: Func<T, U>) => Case<T, V>; not: { true: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: <T>(prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <T, U = unknown>(guard: TypeGuard<U>, out: Get<T, V>) => Case<T, V>; }; }; if: { true: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: <T>(prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <T, U = unknown>(guard: TypeGuard<U>, out: Func<T, U>) => Case<T, V>; not: { true: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: <T>(pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: <T>(prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: <T>(prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <T, U = unknown>(guard: TypeGuard<U>, out: Get<T, V>) => Case<T, V>; }; }; constructor(v: V); case<T>(pred: Predicate<V>, out: Get<T, V>): Case<T, V>; type<T, U = unknown>(guard: TypeGuard<U>, out: Func<T, U>): Case<T, V>; equals<T>(value: V, out: Get<T, V>): Case<T, V>; } declare class Case<T, V = unknown> { protected value: V; protected outcome?: T | undefined; is: { true: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: (prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <U>(guard: TypeGuard<U>, out: Func<T, U>) => Case<T, V>; not: { true: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: (prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <U>(guard: TypeGuard<U>, out: Get<T, V>) => Case<T, V>; }; }; if: { true: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: (prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <U>(guard: TypeGuard<U>, out: Func<T, U>) => Case<T, V>; not: { true: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; false: (pred: Predicate<V>, out: Get<T, V>) => Case<T, V>; truthy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; falsy: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; defined: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; empty: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; valid: (prop: Func<unknown, V>, out: Get<T, V>) => Case<T, V>; in: (prop: Get<Array<V>, V>, out: Get<T, V>) => Case<T, V>; type: <U>(guard: TypeGuard<U>, out: Get<T, V>) => Case<T, V>; }; }; constructor(value: V, outcome?: T | undefined); case(pred: Predicate<V>, out: Get<T, V>): Case<T, V>; type<U>(guard: TypeGuard<U>, out: Func<T, U>): Case<T, V>; equals(value: V, out: Get<T, V>): Case<T, V>; else(alt: Get<T, V>): T; } export declare const choose: <V>(value: V) => CaseBuilder<V>; export {};