UNPKG

4.65 kBTypeScriptView Raw
1/**
2 * A no-arg function, returning T.
3 */
4export type Fn0<T> = () => T;
5/**
6 * A single arg function from A to B.
7 */
8export type Fn<A, B> = (a: A) => B;
9/**
10 * A 2-arg function from A,B to C.
11 */
12export type Fn2<A, B, C> = (a: A, b: B) => C;
13/**
14 * A 3-arg function from A,B,C to D.
15 */
16export type Fn3<A, B, C, D> = (a: A, b: B, c: C) => D;
17/**
18 * A 4-arg function from A,B,C,D to E.
19 */
20export type Fn4<A, B, C, D, E> = (a: A, b: B, c: C, d: D) => E;
21/**
22 * A 5-arg function from A,B,C,D,E to F.
23 */
24export type Fn5<A, B, C, D, E, F> = (a: A, b: B, c: C, d: D, e: E) => F;
25/**
26 * A 6-arg function from A,B,C,D,E,F to G.
27 */
28export type Fn6<A, B, C, D, E, F, G> = (a: A, b: B, c: C, d: D, e: E, f: F) => G;
29/**
30 * A 7-arg function from A,B,C,D,E,F,G to H.
31 */
32export type Fn7<A, B, C, D, E, F, G, H> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G) => H;
33/**
34 * A 8-arg function from A,B,C,D,E,F,G,H to I.
35 */
36export type Fn8<A, B, C, D, E, F, G, H, I> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) => I;
37/**
38 * A 9-arg function from A,B,C,D,E,F,G,H,I to J.
39 */
40export type Fn9<A, B, C, D, E, F, G, H, I, J> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) => J;
41/**
42 * A 10-arg function from A,B,C,D,E,F,G,H,I,J to K.
43 */
44export type Fn10<A, B, C, D, E, F, G, H, I, J, K> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) => K;
45export type FnO<A, B> = (a: A, ...args: any[]) => B;
46export type FnO2<A, B, C> = (a: A, b: B, ...args: any[]) => C;
47export type FnO3<A, B, C, D> = (a: A, b: B, c: C, ...args: any[]) => D;
48export type FnO4<A, B, C, D, E> = (a: A, b: B, c: C, d: D, ...args: any[]) => E;
49export type FnO5<A, B, C, D, E, F> = (a: A, b: B, c: C, d: D, e: E, ...args: any[]) => F;
50export type FnO6<A, B, C, D, E, F, G> = (a: A, b: B, c: C, d: D, e: E, f: F, ...args: any[]) => G;
51export type FnO7<A, B, C, D, E, F, G, H> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, ...args: any[]) => H;
52export type FnO8<A, B, C, D, E, F, G, H, I> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, ...args: any[]) => I;
53export type FnO9<A, B, C, D, E, F, G, H, I, J> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, ...args: any[]) => J;
54export type FnO10<A, B, C, D, E, F, G, H, I, J, K> = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, ...args: any[]) => K;
55/**
56 * An untyped vararg arg function to type T.
57 */
58export type FnAny<T> = (...args: any[]) => T;
59/**
60 * A typed vararg arg function from A to B.
61 */
62export type FnAnyT<A, B> = (...args: A[]) => B;
63/**
64 * 1-arg function with arg of type A and return type B (defaults
65 * to A)
66 */
67export type FnU<A, B = A> = Fn<A, B>;
68/**
69 * 2-arg function with all args uniformly of type A and return type B (defaults
70 * to A)
71 */
72export type FnU2<A, B = A> = Fn2<A, A, B>;
73/**
74 * 3-arg function with all args uniformly of type A and return type B (defaults
75 * to A)
76 */
77export type FnU3<A, B = A> = Fn3<A, A, A, B>;
78/**
79 * 4-arg function with all args uniformly of type A and return type B (defaults
80 * to A)
81 */
82export type FnU4<A, B = A> = Fn4<A, A, A, A, B>;
83/**
84 * 5-arg function with all args uniformly of type A and return type B (defaults
85 * to A)
86 */
87export type FnU5<A, B = A> = Fn5<A, A, A, A, A, B>;
88/**
89 * 6-arg function with all args uniformly of type A and return type B (defaults
90 * to A)
91 */
92export type FnU6<A, B = A> = Fn6<A, A, A, A, A, A, B>;
93/**
94 * 7-arg function with all args uniformly of type A and return type B (defaults
95 * to A)
96 */
97export type FnU7<A, B = A> = Fn7<A, A, A, A, A, A, A, B>;
98/**
99 * 8-arg function with all args uniformly of type A and return type B (defaults
100 * to A)
101 */
102export type FnU8<A, B = A> = Fn8<A, A, A, A, A, A, A, A, B>;
103/**
104 * 9-arg function with all args uniformly of type A and return type B (defaults
105 * to A)
106 */
107export type FnU9<A, B = A> = Fn9<A, A, A, A, A, A, A, A, A, B>;
108/**
109 * 10-arg function with all args uniformly of type A and return type B (defaults
110 * to A)
111 */
112export type FnU10<A, B = A> = Fn10<A, A, A, A, A, A, A, A, A, A, B>;
113export type FnN = FnU<number>;
114export type FnN2 = FnU2<number>;
115export type FnN3 = FnU3<number>;
116export type FnN4 = FnU4<number>;
117export type FnN5 = FnU5<number>;
118export type FnN6 = FnU6<number>;
119export type FnN7 = FnU7<number>;
120export type FnN8 = FnU8<number>;
121export type FnN9 = FnU9<number>;
122export type FnN10 = FnU10<number>;
123/**
124 * Identity function: `(x) => x`
125 *
126 * @param x
127 */
128export declare const identity: <T>(x: T) => T;
129/**
130 * Zero-arg function always returning true.
131 */
132export declare const always: () => boolean;
133/**
134 * Zero-arg function always returning false.
135 */
136export declare const never: () => boolean;
137//# sourceMappingURL=fn.d.ts.map
\No newline at end of file