@thisisagile/easy
Version:
Straightforward library for building domain-driven microservice architectures
41 lines (40 loc) • 1.6 kB
TypeScript
import { Primitive } from '../types/Primitive';
import { Constructor } from '../types/Constructor';
import { PageList } from '../types/PageList';
import { List } from '../types/List';
import { DontInfer } from '../types/Types';
type Func<T = unknown> = (a: any, key?: string) => T;
type Viewer = {
key: string;
f: Func;
};
type ViewType<V = any> = Primitive | Constructor | Func | View<V> | undefined;
type ViewRecord<V = any> = Partial<Record<keyof V, ViewType>>;
export declare const toViewer: (key: string, value: ViewType) => Viewer;
export declare class View<V = any> {
private views;
readonly startsFrom: 'scratch' | 'source';
readonly viewers: Viewer[];
constructor(views?: ViewRecord<V>, startsFrom?: 'scratch' | 'source', viewers?: Viewer[]);
get fromSource(): View<V>;
from<T = unknown>(source: PageList<T>): PageList<V>;
from<T = unknown>(source: List<T>): List<V>;
from<T = unknown>(source: T[]): V[];
from<T = unknown>(source: T): V;
same: (one?: unknown, another?: unknown) => boolean;
private reduce;
}
export declare const isSimpleView: (a: unknown) => a is View;
export declare const view: <V = any>(views: ViewRecord<DontInfer<V>>) => View<V>;
export declare const views: {
ignore: symbol;
keep: symbol;
skip: symbol;
value: (value: unknown) => () => unknown;
or: {
key: (altKey: string) => (a: unknown, key?: string) => unknown;
value: (altValue: unknown) => (a: unknown, key?: string) => unknown;
func: (altFunc: Func) => (a: unknown, key?: string) => unknown;
};
};
export {};