UNPKG

sussy-util

Version:
144 lines (143 loc) 5.62 kB
import { AnyFunction, Constructor } from '../Types'; declare class IsSomething { private static instance; private constructor(); /** * If the argument is an array, return true, otherwise return false. * @param {any} arg - any * @returns a boolean value. */ isArray(arg: unknown): arg is Array<unknown>; /** * If the argument is not null and is either a boolean or a string that is either "true" or * "false", then return true * @param {any} arg - any * @returns A boolean value. */ isBoolean(arg: unknown): arg is boolean; /** * If the argument is a function, try to call it. If it throws an error with the message "Class * constructor [class name] cannot be invoked without 'new'", then it's a class * @param {any} arg - any - The argument to check if it's a class. * @returns A boolean value. */ isClass(arg: unknown): arg is Constructor<object>; /** * If the argument is an object, and it's constructor is the Date constructor, and it's an instance * of Date, then it's a Date * @param {any} arg - any * @returns The constructor of the Date object. */ isDate(arg: unknown): arg is Date; /** * It returns true if the argument is not undefined * @param {any} arg - any * @returns The type of the argument. */ isDefined(arg: unknown): boolean; /** * If the argument is not null or undefined, then it has a value * @param {any} arg - any * @returns The return value is a boolean. */ isEmpty(arg: unknown): boolean; /** * If the argument is an object, and it's constructor is the Error constructor, and it's an instance * of Error, then it's an error * @param {any} arg - any * @returns The constructor of the Error object. */ isError(arg: unknown): arg is Error; /** * If the input is a number, return true if the number is even, otherwise return false. * @param {number} num - number - This is the parameter that we are passing into the function. * @returns A function that takes a number and returns a boolean or null. */ isEven(num: number): boolean; /** * If the object is a function, and it's not a class, then it's a function. * @param {any} a - any * @returns A boolean value. */ isFunction(a: unknown): a is AnyFunction; /** * It returns true if the argument is either Infinity or -Infinity * @param {any} arg - any * @returns a boolean value. */ isInfinite(arg: unknown): boolean; /** * If the argument is null or undefined, return true. Otherwise, return false * @param {any} arg - any * @returns The return value is a boolean. */ isNullorUndefined(arg: unknown): arg is null | undefined; /** * It returns true if the argument is a number or a string that contains only digits * @param {any} arg - any */ isNumber(arg: unknown): arg is number; /** * If the argument is not null, and is an object, and is not an array, then return true. * @param {any} arg - any */ isObject(arg: unknown): arg is object; /** * If the number is less than 2, it's not prime. If it's even, it's not prime. If it's divisible by * any odd number up to the square root of the number, it's not prime. Otherwise, it's prime * @param {number} num - number - The number to check if it's prime. * @returns A boolean value. */ isPrime(num: number): boolean; /** * If the argument is null, undefined, a string, a number, a boolean, or a symbol, then return * true, otherwise return false. * @param {any} arg - any * @returns A boolean value. */ isPrimitive(arg: unknown): arg is number | null | undefined | string | boolean | symbol; /** * If the argument is an instance of RegExp or the argument's constructor is the RegExp * constructor, then return true * @param {any} arg - any * @returns a boolean value. */ isRegExp(arg: unknown): arg is RegExp; /** * It checks if the argument is a string, or if it's a number, it checks if it can be converted to * a string * @param {any} arg - any */ isString(arg: unknown): arg is string; /** * If the argument is a symbol or an object that is an instance of the Symbol class, then return * true, otherwise return false. * @param {any} arg - any * @returns a boolean value. */ isSymbol(arg: unknown): arg is symbol; /** * This function returns true if the type of the argument is the same as the type passed in as a * parameter. * @param {any} arg - The argument to check the type of. * @param {String} type - The type of the argument. * @returns The type of the argument. */ isType(arg: unknown, type: string): boolean; /** * If the constructor is a class, return whether the value is an instance of the constructor. * @param {any} value - any - The value to check. * @param {Function} constructor - The constructor function to check against. * @returns The return value is a boolean. */ isInstanceOf(value: unknown, constructor: Constructor<object>): boolean | null; /** * If the date is not a number, then it's not a valid date. * @param {Date} date - The date to check. * @returns The return value is a boolean. */ isDateValid(date: Date): boolean; static getInstance(): IsSomething; } declare const _default: IsSomething; export default _default;