/
types.ts
24 lines (18 loc) · 969 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Instance } from "./Instance";
/**
* Generic types to simplify the specification of function prototypes used in callbacks.
*/
export namespace types {
/** Prototype of a class constructor. */
export type Constructor<T> = new (...args: any[]) => T;
/** Prototype of a function taking a single argument of a specific type and returning anything. */
export type Consumer<T> = (arg: T) => any;
/** Prototype of a function taking a single argument of a specific type and returning anything. */
export type Behaviour<T> = (arg: T, instance: Instance) => any;
/** Prototype for any function taking a single parameter. */
export type Function<T, R> = (arg: T) => R;
/** Prototype of a function taking a single argument of a specific type and returning a boolean result. */
export type Predicate<T> = (arg: T) => boolean;
/** Prototype of a function taking no arguments and returning result of a specific type. */
export type Producer<T> = () => T;
}