1 | export declare type AnyFunction = (...args: any[]) => any;
|
---|
2 | export declare type AnyAsyncFunction = (...args: any[]) => Promise<any>;
|
---|
3 | export declare type AnyClass = new (...args: any[]) => any;
|
---|
4 | export declare type PlainObject = Record<string | number | symbol, any>;
|
---|
5 | declare type TypeGuard<A, B extends A> = (payload: A) => payload is B;
|
---|
6 | /**
|
---|
7 | * Returns the object type of the given payload
|
---|
8 | *
|
---|
9 | * @param {*} payload
|
---|
10 | * @returns {string}
|
---|
11 | */
|
---|
12 | export declare function getType(payload: any): string;
|
---|
13 | /**
|
---|
14 | * Returns whether the payload is undefined
|
---|
15 | *
|
---|
16 | * @param {*} payload
|
---|
17 | * @returns {payload is undefined}
|
---|
18 | */
|
---|
19 | export declare function isUndefined(payload: any): payload is undefined;
|
---|
20 | /**
|
---|
21 | * Returns whether the payload is null
|
---|
22 | *
|
---|
23 | * @param {*} payload
|
---|
24 | * @returns {payload is null}
|
---|
25 | */
|
---|
26 | export declare function isNull(payload: any): payload is null;
|
---|
27 | /**
|
---|
28 | * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
---|
29 | *
|
---|
30 | * @param {*} payload
|
---|
31 | * @returns {payload is PlainObject}
|
---|
32 | */
|
---|
33 | export declare function isPlainObject(payload: any): payload is PlainObject;
|
---|
34 | /**
|
---|
35 | * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
---|
36 | *
|
---|
37 | * @param {*} payload
|
---|
38 | * @returns {payload is PlainObject}
|
---|
39 | */
|
---|
40 | export declare function isObject(payload: any): payload is PlainObject;
|
---|
41 | /**
|
---|
42 | * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
|
---|
43 | *
|
---|
44 | * @param {*} payload
|
---|
45 | * @returns {payload is { [K in any]: never }}
|
---|
46 | */
|
---|
47 | export declare function isEmptyObject(payload: any): payload is {
|
---|
48 | [K in any]: never;
|
---|
49 | };
|
---|
50 | /**
|
---|
51 | * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
|
---|
52 | *
|
---|
53 | * @param {*} payload
|
---|
54 | * @returns {payload is PlainObject}
|
---|
55 | */
|
---|
56 | export declare function isFullObject(payload: any): payload is PlainObject;
|
---|
57 | /**
|
---|
58 | * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
|
---|
59 | *
|
---|
60 | * @param {*} payload
|
---|
61 | * @returns {payload is PlainObject}
|
---|
62 | */
|
---|
63 | export declare function isAnyObject(payload: any): payload is PlainObject;
|
---|
64 | /**
|
---|
65 | * Returns whether the payload is an object like a type passed in < >
|
---|
66 | *
|
---|
67 | * Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.
|
---|
68 | *
|
---|
69 | * @template T this must be passed in < >
|
---|
70 | * @param {*} payload
|
---|
71 | * @returns {payload is T}
|
---|
72 | */
|
---|
73 | export declare function isObjectLike<T extends PlainObject>(payload: any): payload is T;
|
---|
74 | /**
|
---|
75 | * Returns whether the payload is a function (regular or async)
|
---|
76 | *
|
---|
77 | * @param {*} payload
|
---|
78 | * @returns {payload is AnyFunction}
|
---|
79 | */
|
---|
80 | export declare function isFunction(payload: any): payload is AnyFunction;
|
---|
81 | /**
|
---|
82 | * Returns whether the payload is an array
|
---|
83 | *
|
---|
84 | * @param {any} payload
|
---|
85 | * @returns {payload is any[]}
|
---|
86 | */
|
---|
87 | export declare function isArray(payload: any): payload is any[];
|
---|
88 | /**
|
---|
89 | * Returns whether the payload is a an array with at least 1 item
|
---|
90 | *
|
---|
91 | * @param {*} payload
|
---|
92 | * @returns {payload is any[]}
|
---|
93 | */
|
---|
94 | export declare function isFullArray(payload: any): payload is any[];
|
---|
95 | /**
|
---|
96 | * Returns whether the payload is a an empty array
|
---|
97 | *
|
---|
98 | * @param {*} payload
|
---|
99 | * @returns {payload is []}
|
---|
100 | */
|
---|
101 | export declare function isEmptyArray(payload: any): payload is [];
|
---|
102 | /**
|
---|
103 | * Returns whether the payload is a string
|
---|
104 | *
|
---|
105 | * @param {*} payload
|
---|
106 | * @returns {payload is string}
|
---|
107 | */
|
---|
108 | export declare function isString(payload: any): payload is string;
|
---|
109 | /**
|
---|
110 | * Returns whether the payload is a string, BUT returns false for ''
|
---|
111 | *
|
---|
112 | * @param {*} payload
|
---|
113 | * @returns {payload is string}
|
---|
114 | */
|
---|
115 | export declare function isFullString(payload: any): payload is string;
|
---|
116 | /**
|
---|
117 | * Returns whether the payload is ''
|
---|
118 | *
|
---|
119 | * @param {*} payload
|
---|
120 | * @returns {payload is string}
|
---|
121 | */
|
---|
122 | export declare function isEmptyString(payload: any): payload is string;
|
---|
123 | /**
|
---|
124 | * Returns whether the payload is a number (but not NaN)
|
---|
125 | *
|
---|
126 | * This will return `false` for `NaN`!!
|
---|
127 | *
|
---|
128 | * @param {*} payload
|
---|
129 | * @returns {payload is number}
|
---|
130 | */
|
---|
131 | export declare function isNumber(payload: any): payload is number;
|
---|
132 | /**
|
---|
133 | * Returns whether the payload is a boolean
|
---|
134 | *
|
---|
135 | * @param {*} payload
|
---|
136 | * @returns {payload is boolean}
|
---|
137 | */
|
---|
138 | export declare function isBoolean(payload: any): payload is boolean;
|
---|
139 | /**
|
---|
140 | * Returns whether the payload is a regular expression (RegExp)
|
---|
141 | *
|
---|
142 | * @param {*} payload
|
---|
143 | * @returns {payload is RegExp}
|
---|
144 | */
|
---|
145 | export declare function isRegExp(payload: any): payload is RegExp;
|
---|
146 | /**
|
---|
147 | * Returns whether the payload is a Map
|
---|
148 | *
|
---|
149 | * @param {*} payload
|
---|
150 | * @returns {payload is Map<any, any>}
|
---|
151 | */
|
---|
152 | export declare function isMap(payload: any): payload is Map<any, any>;
|
---|
153 | /**
|
---|
154 | * Returns whether the payload is a WeakMap
|
---|
155 | *
|
---|
156 | * @param {*} payload
|
---|
157 | * @returns {payload is WeakMap<any, any>}
|
---|
158 | */
|
---|
159 | export declare function isWeakMap(payload: any): payload is WeakMap<any, any>;
|
---|
160 | /**
|
---|
161 | * Returns whether the payload is a Set
|
---|
162 | *
|
---|
163 | * @param {*} payload
|
---|
164 | * @returns {payload is Set<any>}
|
---|
165 | */
|
---|
166 | export declare function isSet(payload: any): payload is Set<any>;
|
---|
167 | /**
|
---|
168 | * Returns whether the payload is a WeakSet
|
---|
169 | *
|
---|
170 | * @param {*} payload
|
---|
171 | * @returns {payload is WeakSet<any>}
|
---|
172 | */
|
---|
173 | export declare function isWeakSet(payload: any): payload is WeakSet<any>;
|
---|
174 | /**
|
---|
175 | * Returns whether the payload is a Symbol
|
---|
176 | *
|
---|
177 | * @param {*} payload
|
---|
178 | * @returns {payload is symbol}
|
---|
179 | */
|
---|
180 | export declare function isSymbol(payload: any): payload is symbol;
|
---|
181 | /**
|
---|
182 | * Returns whether the payload is a Date, and that the date is valid
|
---|
183 | *
|
---|
184 | * @param {*} payload
|
---|
185 | * @returns {payload is Date}
|
---|
186 | */
|
---|
187 | export declare function isDate(payload: any): payload is Date;
|
---|
188 | /**
|
---|
189 | * Returns whether the payload is a Blob
|
---|
190 | *
|
---|
191 | * @param {*} payload
|
---|
192 | * @returns {payload is Blob}
|
---|
193 | */
|
---|
194 | export declare function isBlob(payload: any): payload is Blob;
|
---|
195 | /**
|
---|
196 | * Returns whether the payload is a File
|
---|
197 | *
|
---|
198 | * @param {*} payload
|
---|
199 | * @returns {payload is File}
|
---|
200 | */
|
---|
201 | export declare function isFile(payload: any): payload is File;
|
---|
202 | /**
|
---|
203 | * Returns whether the payload is a Promise
|
---|
204 | *
|
---|
205 | * @param {*} payload
|
---|
206 | * @returns {payload is Promise<any>}
|
---|
207 | */
|
---|
208 | export declare function isPromise(payload: any): payload is Promise<any>;
|
---|
209 | /**
|
---|
210 | * Returns whether the payload is an Error
|
---|
211 | *
|
---|
212 | * @param {*} payload
|
---|
213 | * @returns {payload is Error}
|
---|
214 | */
|
---|
215 | export declare function isError(payload: any): payload is Error;
|
---|
216 | /**
|
---|
217 | * Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
|
---|
218 | *
|
---|
219 | * @param {*} payload
|
---|
220 | * @returns {payload is typeof NaN}
|
---|
221 | */
|
---|
222 | export declare function isNaNValue(payload: any): payload is typeof NaN;
|
---|
223 | /**
|
---|
224 | * Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol)
|
---|
225 | *
|
---|
226 | * @param {*} payload
|
---|
227 | * @returns {(payload is boolean | null | undefined | number | string | symbol)}
|
---|
228 | */
|
---|
229 | export declare function isPrimitive(payload: any): payload is boolean | null | undefined | number | string | symbol;
|
---|
230 | /**
|
---|
231 | * Returns true whether the payload is null or undefined
|
---|
232 | *
|
---|
233 | * @param {*} payload
|
---|
234 | * @returns {(payload is null | undefined)}
|
---|
235 | */
|
---|
236 | export declare const isNullOrUndefined: TypeGuard<any, null | undefined>;
|
---|
237 | export declare function isOneOf<A, B extends A, C extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>): TypeGuard<A, B | C>;
|
---|
238 | export declare function isOneOf<A, B extends A, C extends A, D extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>): TypeGuard<A, B | C | D>;
|
---|
239 | export declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>): TypeGuard<A, B | C | D | E>;
|
---|
240 | export declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A, F extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>, e: TypeGuard<A, F>): TypeGuard<A, B | C | D | E | F>;
|
---|
241 | /**
|
---|
242 | * Does a generic check to check that the given payload is of a given type.
|
---|
243 | * In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!);
|
---|
244 | * It will, however, differentiate between object and null
|
---|
245 | *
|
---|
246 | * @template T
|
---|
247 | * @param {*} payload
|
---|
248 | * @param {T} type
|
---|
249 | * @throws {TypeError} Will throw type error if type is an invalid type
|
---|
250 | * @returns {payload is T}
|
---|
251 | */
|
---|
252 | export declare function isType<T extends AnyFunction | AnyClass>(payload: any, type: T): payload is T;
|
---|
253 | export {};
|
---|