/** * Represents an asynchronous function. */ type AsyncFunction = Array, TReturn = any> = (...args: TArgs) => Promise; /** * Represents the type of a class. * * @since v1.5.6 */ type ConstructorType = new (...args: any[]) => T; /** * Represents the type of a function. * * @since v1.5.6 */ type FunctionType = (...args: any[]) => T; /** * @private */ type ThisArgsFn = (thisArg: T, ...args: any[]) => T; /** * Defines the type of a primitive wrapper constructor. */ interface PrimitiveWrapperCtor { prototype: { valueOf: FunctionType; }; } /** * Defines a base utility class. */ export declare abstract class Utils { /** * @constructor * * @private */ private constructor(); /** * Gets the global object. */ static get globalThat(): typeof globalThis | (Window & typeof globalThis); /** * Checks whether the specified value is `arguments`. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is `arguments`. */ static isArguments(value?: any): value is IArguments; /** * Checks whether the specified value is an asynchronous function. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is an asynchronous function. */ static isAsyncFunction(value?: any): value is AsyncFunction; /** * Checks whether the given value is of boolean type. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is of boolean type. */ static isBoolean(value?: any): value is boolean; /** * Checks whether the specified value is of type `DataView`. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is of type `DataView`. */ static isDataView(value?: any): value is DataView; /** * Checks whether the given value is defined. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is defined. */ static isDefined(value?: T | undefined): value is T; /** * Checks whether the specified value is an `Error` instance. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is an error instance. * * @since v1.5.6 */ static isError(value?: any): value is Error; /** * Checks whether the given value is falsy i. e.: `null`, `undefined`, * `false`, `NaN`, `0`, `-0`, `0n` or `''`. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is falsy. */ static isFalsy(value?: any): value is null | undefined | false | 0 | -0 | 0n | ''; /** * Checks whether the specified value is a `File` instance. * * **Usage Examples:** * ```typescript * Utils.isFile(null); // false * Utils.isFile(new File([], "abc")); // true * ``` * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a `File` instance. * * @since v1.5.6 */ static isFile(value?: any): value is File; /** * Checks whether the specified value is a `FormData` object. * * **Usage Examples:** * ```typescript * const formData = new FormData(); * formData.append('a', 'abc'); * Utils.isFormData(formData); // true * ``` * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a `FormData` object. * * @since v1.6.7 */ static isFormData(value?: any): value is FormData; /** * Checks whether the given value is a function. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is a function. */ static isFunction(value?: any): value is Function; /** * Checks whether the specified value is a generator object. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a generator object. */ static isGeneratorObject(value?: any): value is Generator; /** * Checks whether the specified value is a JSON string. * * @param {*} value Contains some value. * @param {Boolean} approx Contains whether not to deep check the * specified value whether it is a JSON string. * @return {Boolean} whether the specified value is a JSON string. */ static isJson(value?: any, approx?: boolean): boolean; /** * Checks whether the given value is neither `null` nor `undefined`. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is neither `null` nor * `undefined`. */ static isNotNil(value?: T | null | undefined): value is T; /** * Checks whether the given value is not `null`. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is not `null`. */ static isNotNull(value?: T | null): value is T; /** * Checks whether the given value is not `undefined`. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is not `undefined`. */ static isNotUndefined(value?: T | undefined): value is T; /** * Checks whether the given value is null. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is `null`. */ static isNull(value?: any): value is null; /** * Checks whether the given value is `null` or `undefined`. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is `null` or `undefined`. */ static isNullOrUndefined(value?: any): value is null | undefined; /** * Checks whether the given value is of primitive type. In JavaScript * there are 7 primitive types: `string`, `number`, `bigint`, `boolean`, * `undefined`, `symbol` and `null`. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is of primitive type. */ static isPrimitive(value?: any): value is bigint | boolean | null | number | string | symbol | undefined; /** * Checks whether the specified value is a `Promise`. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a JavaScript `promise`. * * @since v1.5.6 */ static isPromise(value?: any): value is Promise; /** * Checks whether the specified value is a `PromiseLike` object. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a `PromiseLike` object. * * @since v1.6.7 */ static isPromiseLike(value?: any): value is PromiseLike; /** * Checks whether the specified value is a regular expression. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a regular expression. */ static isRegExp(value?: any): value is RegExp; /** * Checks whether the specified value is a symbol. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a symbol. */ static isSymbol(value?: any): value is symbol; /** * Checks whether the specified value is a `Symbol` object. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a `Symbol` object. */ static isSymbolObject(value?: any): value is (typeof Symbol extends undefined ? false : Symbol); /** * Checks whether the given value is not falsy i. e. not: `null`, `undefined`, * `false`, `NaN`, `0`, `-0`, `0n` or `''`. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is not falsy. */ static isTruthy(value?: T | null | undefined | false | 0 | -0 | 0n | ''): value is T; /** * Checks whether the given value is not defined. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is not defined. */ static isUndefined(value?: any): value is undefined; /** * Checks whether the specified value is a web assembly module. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a web assembly module. */ static isWebAssemblyCompiledModule(value?: any): value is WebAssembly.Module; /** * Checks whether the specified value is a primitive wrapper object. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a primitive wrapper * object. */ static isWrappedPrimitive(value?: any): boolean; /** * Uncurries the specified function. * * @param {Function} func Contains some function. * @return {ThisArgsFn} an uncurried function. */ static uncurry(func: FunctionType): ThisArgsFn; /** * Checks whether the specified wrapper type is supported. * * @param {*} value Contains some value. * @param {TWrapper} wrapperType Contains the wrapper type constructor. * @return {Boolean} whether the specified wrapper type is supported. * * @private */ static __isPrimitiveWrapperSupported(value: any, wrapperType: TWrapper): boolean; } export type { AsyncFunction, ConstructorType, FunctionType, };