UNPKG

6.53 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Predicate } from './lib/predicates/predicate';
3import { StringPredicate } from './lib/predicates/string';
4import { NumberPredicate } from './lib/predicates/number';
5import { BooleanPredicate } from './lib/predicates/boolean';
6import { ArrayPredicate } from './lib/predicates/array';
7import { ObjectPredicate } from './lib/predicates/object';
8import { DatePredicate } from './lib/predicates/date';
9import { ErrorPredicate } from './lib/predicates/error';
10import { MapPredicate } from './lib/predicates/map';
11import { WeakMapPredicate } from './lib/predicates/weak-map';
12import { SetPredicate } from './lib/predicates/set';
13import { WeakSetPredicate } from './lib/predicates/weak-set';
14/**
15 * @hidden
16 */
17export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
18export interface Ow {
19 /**
20 * Test if the value matches the predicate.
21 *
22 * @param value Value to test.
23 * @param predicate Predicate to test against.
24 */
25 <T>(value: T, predicate: Predicate<T>): void;
26 /**
27 * Create a reusable validator.
28 *
29 * @param predicate Predicate used in the validator function.
30 */
31 create<T>(predicate: Predicate<T>): (value: T) => void;
32 /**
33 * Test that the value matches at least one of the given predicates.
34 */
35 any<T1>(p1: Predicate<T1>): Predicate<T1>;
36 any<T1, T2>(p1: Predicate<T1>, p2: Predicate<T2>): Predicate<T1 | T2>;
37 any<T1, T2, T3>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>): Predicate<T1 | T2 | T3>;
38 any<T1, T2, T3, T4>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>, p4: Predicate<T4>): Predicate<T1 | T2 | T3 | T4>;
39 any<T1, T2, T3, T4, T5>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>, p4: Predicate<T4>, p5: Predicate<T5>): Predicate<T1 | T2 | T3 | T4 | T5>;
40 any<T1, T2, T3, T4, T5, T6>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>, p4: Predicate<T4>, p5: Predicate<T5>, p6: Predicate<T6>): Predicate<T1 | T2 | T3 | T4 | T5 | T6>;
41 any<T1, T2, T3, T4, T5, T6, T7>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>, p4: Predicate<T4>, p5: Predicate<T5>, p6: Predicate<T6>, p7: Predicate<T7>): Predicate<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
42 any<T1, T2, T3, T4, T5, T6, T7, T8>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>, p4: Predicate<T4>, p5: Predicate<T5>, p6: Predicate<T6>, p7: Predicate<T7>, p8: Predicate<T8>): Predicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
43 any<T1, T2, T3, T4, T5, T6, T7, T8, T9>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>, p4: Predicate<T4>, p5: Predicate<T5>, p6: Predicate<T6>, p7: Predicate<T7>, p8: Predicate<T8>, p9: Predicate<T9>): Predicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
44 any<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(p1: Predicate<T1>, p2: Predicate<T2>, p3: Predicate<T3>, p4: Predicate<T4>, p5: Predicate<T5>, p6: Predicate<T6>, p7: Predicate<T7>, p8: Predicate<T8>, p9: Predicate<T9>, p10: Predicate<T10>): Predicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
45 any(...predicate: Predicate[]): Predicate;
46 /**
47 * Test the value to be a string.
48 */
49 readonly string: StringPredicate;
50 /**
51 * Test the value to be a number.
52 */
53 readonly number: NumberPredicate;
54 /**
55 * Test the value to be a boolean.
56 */
57 readonly boolean: BooleanPredicate;
58 /**
59 * Test the value to be undefined.
60 */
61 readonly undefined: Predicate<undefined>;
62 /**
63 * Test the value to be null.
64 */
65 readonly null: Predicate<null>;
66 /**
67 * Test the value to be null or undefined.
68 */
69 readonly nullOrUndefined: Predicate<null | undefined>;
70 /**
71 * Test the value to be not a number.
72 */
73 readonly nan: Predicate<number>;
74 /**
75 * Test the value to be a Symbol.
76 */
77 readonly symbol: Predicate<Symbol>;
78 /**
79 * Test the value to be an array.
80 */
81 readonly array: ArrayPredicate;
82 /**
83 * Test the value to be an object.
84 */
85 readonly object: ObjectPredicate;
86 /**
87 * Test the value to be a Date.
88 */
89 readonly date: DatePredicate;
90 /**
91 * Test the value to be an Error.
92 */
93 readonly error: ErrorPredicate;
94 /**
95 * Test the value to be a Map.
96 */
97 readonly map: MapPredicate;
98 /**
99 * Test the value to be a WeakMap.
100 */
101 readonly weakMap: WeakMapPredicate;
102 /**
103 * Test the value to be a Set.
104 */
105 readonly set: SetPredicate;
106 /**
107 * Test the value to be a WeakSet.
108 */
109 readonly weakSet: WeakSetPredicate;
110 /**
111 * Test the value to be a Function.
112 */
113 readonly function: Predicate<Function>;
114 /**
115 * Test the value to be a Buffer.
116 */
117 readonly buffer: Predicate<Buffer>;
118 /**
119 * Test the value to be a RegExp.
120 */
121 readonly regExp: Predicate<RegExp>;
122 /**
123 * Test the value to be a Promise.
124 */
125 readonly promise: Predicate<Promise<any>>;
126 /**
127 * Test the value to be a typed array.
128 */
129 readonly typedArray: Predicate<TypedArray>;
130 /**
131 * Test the value to be a Int8Array.
132 */
133 readonly int8Array: Predicate<Int8Array>;
134 /**
135 * Test the value to be a Uint8Array.
136 */
137 readonly uint8Array: Predicate<Uint8Array>;
138 /**
139 * Test the value to be a Uint8ClampedArray.
140 */
141 readonly uint8ClampedArray: Predicate<Uint8ClampedArray>;
142 /**
143 * Test the value to be a Int16Array.
144 */
145 readonly int16Array: Predicate<Int16Array>;
146 /**
147 * Test the value to be a Uint16Array.
148 */
149 readonly uint16Array: Predicate<Uint16Array>;
150 /**
151 * Test the value to be a Int32Array.
152 */
153 readonly int32Array: Predicate<Int32Array>;
154 /**
155 * Test the value to be a Uint32Array.
156 */
157 readonly uint32Array: Predicate<Uint32Array>;
158 /**
159 * Test the value to be a Float32Array.
160 */
161 readonly float32Array: Predicate<Float32Array>;
162 /**
163 * Test the value to be a Float64Array.
164 */
165 readonly float64Array: Predicate<Float64Array>;
166 /**
167 * Test the value to be a ArrayBuffer.
168 */
169 readonly arrayBuffer: Predicate<ArrayBuffer>;
170 /**
171 * Test the value to be a DataView.
172 */
173 readonly dataView: Predicate<DataView>;
174 /**
175 * Test the value to be Iterable.
176 */
177 readonly iterable: Predicate<Iterable<any>>;
178}
179declare const _default: Ow;
180export default _default;