UNPKG

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