UNPKG

@thisisagile/easy

Version:

Straightforward library for building domain-driven microservice architectures

17 lines (16 loc) 981 B
import { Get } from './Get'; import { Optional } from './Types'; export type Constructor<T = unknown> = { new (...args: any[]): T; }; export type Construct<Out, In = any> = Get<Out, In> | Constructor<Out>; export declare const isConstructor: <T>(c?: unknown) => c is Constructor<T>; export declare const isInstance: <T>(ctor: Constructor<T>, o?: unknown) => o is T; export declare const ofConstruct: <T>(c: Construct<T>, ...args: unknown[]) => T; export declare const toName: (subject?: unknown, postfix?: string) => string; export declare const on: <T, R>(t: T, f: (t: T) => R) => R extends Promise<unknown> ? Promise<T> : T; export declare const use: <T, Out>(t: T, f: (t: T) => Out) => Out; export declare const ifA: <T>(c: Constructor<T>, t?: unknown, alt?: unknown) => Optional<T>; export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>; }[Keys];