UNPKG

1.35 kBPlain TextView Raw
1/* istanbul ignore next */
2/* tslint:disable:no-empty */
3export const NOOP = () => {};
4/* tslint:enable:no-empty */
5
6export type Constructable<T> = {
7 new (...args: Array<any>): T
8};
9
10export type IneedaKey<T> = keyof T | keyof IneedaProxy<T> | keyof Object | keyof Function;
11
12export type IneedaInterceptorToken = {};
13export type IneedaInterceptorFunction<T, K extends keyof T> = (value?: T[K], key?: K, values?: Partial<T>, target?: T) => any;
14export type IneedaInterceptor<T> = IneedaInterceptorFunction<T, keyof T> | Partial<T>;
15export type IneedaInterceptorOrToken<T> = IneedaInterceptor<T> | IneedaInterceptorToken;
16
17export interface IneedaProxy<T> {
18 hasOwnProperty (): boolean;
19 intercept (interceptor: IneedaInterceptorOrToken<T>): T;
20 reset (): T;
21 toJSON (): Partial<T>;
22 toString (): string;
23}
24
25export interface IneedaFactory <T> {
26 instances?: Array<T & IneedaProxy<T>>;
27 (): T & IneedaProxy<T>;
28 getLatest? (): T & IneedaProxy<T>;
29}
30
31export interface IneedaApi {
32 <T> (values?: Partial<T>): T & IneedaProxy<T>;
33 factory <T> (values?: Partial<T>): IneedaFactory<T & IneedaProxy<T>>;
34 instanceof <T> (constructor: Constructable<T>, values?: Partial<T>): T & IneedaProxy<T>;
35 intercept <T> (interceptorOrToken: IneedaInterceptorOrToken<T>, interceptor?: IneedaInterceptor<T>): void;
36 reset (): void;
37}