UNPKG

@pkt/utils

Version:

95 lines (94 loc) 2.77 kB
import type { SafeAny } from '@pkt/utils/types'; /** * Check if value is a function. */ export declare function isFunction(value: SafeAny): boolean; /** * Check if value is a valid JSON. */ export declare function isJson(value: SafeAny): boolean; /** * Check if value is a string primitive. */ export declare function isString(value: SafeAny): boolean; /** * Check if value is a type primitive */ export declare function is(value: SafeAny, type: string): boolean; /** * Check if value is a string primitive. * * isNonEmptyString(''); // -> false */ export declare function isNonEmptyString(value: string | null | undefined | SafeAny): boolean; /** * Check if value is undefined. * * isUndefined(void 0); // -> true */ export declare function isUndefined(value: undefined | SafeAny): boolean; export declare function isUndefinedOrEmptyString(value: undefined | string | SafeAny): boolean; /** * Check if value is an Null. */ export declare function isNull(value: null | SafeAny): boolean; /** * Check if value is null or undefined, the same as value == null. * * isNullOrUndefined(null); // -> true * isNullOrUndefined(undefined); // -> true * isNullOrUndefined(void 0); // -> true */ export declare function isNullOrUndefined(obj: null | undefined | SafeAny): boolean; /** * Check if value is the language type of Object. * * isObject({}); // -> true * isObject([]); // -> true */ export declare function isObject(value: SafeAny): boolean; export declare function isObjectAndNotArray(value: SafeAny): boolean; export declare function isObjectAndNotArrayNotNode(value: SafeAny): boolean; export declare function isNode(value: SafeAny): value is Node; /** * exists * @param obj * @returns boolean */ export declare function exists(obj: SafeAny): boolean; /** * Check if value is classified as a Number primitive or object. */ export declare function isNum(value: string | SafeAny): boolean; /** * Checks if value is classified as a Integer. */ export declare function isInt(value: number | SafeAny): boolean; /** * Checks if value is classified as a Decimal. */ export declare function isDecimal(value: number | SafeAny): boolean; /** * Check if number is odd. */ export declare function isOdd(value: number | SafeAny): boolean; /** * Check if value is an IdCard. */ export declare function isIdCard(value: string): boolean; /** * Check if value is an Mobile. */ export declare function isMobile(value: string): boolean; /** * Check if value is an url address. */ export declare function isUrl(value: string): boolean; /** * Check if value is an IP address. */ export declare function isIp(value: string): boolean; /** * Loosely validate an email address. */ export declare function isEmail(value: string): boolean;