|
| 1 | +export const isArray = (value: any): value is any[] => Array.isArray(value); |
| 2 | +export const isString = (value: any): value is string => |
| 3 | + typeof value === "string"; |
| 4 | +export const isFunction = (value: any): value is Function => |
| 5 | + typeof value === "function"; |
| 6 | +export const isObject = (value: any): value is object => |
| 7 | + Object.prototype.toString.call(value) === "[object Object]"; |
| 8 | +export const hasLength = (arg: any): boolean => Boolean(arg && arg.length > 0); |
| 9 | +export const isBoolean = (value: any): value is boolean => |
| 10 | + typeof value === "boolean"; |
| 11 | +export const isDate = (value: any): value is Date => |
| 12 | + value instanceof Date && !isNaN(value as any); |
| 13 | +export const isNumber = (value: any): value is number => |
| 14 | + typeof value === "number"; |
| 15 | +export const isObjectEmpty = (value: any): boolean => |
| 16 | + Object.keys(value).length === 0; |
| 17 | +export const isStringHasLength = (value: any): boolean => |
| 18 | + isString(value) && hasLength(value); |
| 19 | +export const isStringEmpty = (value: any): boolean => |
| 20 | + isString(value) && !hasLength(value); |
| 21 | +export const isArrayHasLength = (value: any): boolean => |
| 22 | + isArray(value) && hasLength(value); |
| 23 | +export const isArrayEmpty = (value: any): boolean => |
| 24 | + isArray(value) && !hasLength(value); |
| 25 | +export const isObjectHasProps = (value: any): boolean => |
| 26 | + isObject(value) && !isObjectEmpty(value); |
| 27 | +export const isBooleanTruthy = (value: any): boolean => |
| 28 | + isBoolean(value) && value; |
| 29 | +export const isBooleanFalsey = (value: any): boolean => |
| 30 | + isBoolean(value) && !value; |
| 31 | +export const isHTML = (value: any): boolean => { |
| 32 | + const htmlRegex = /<[^>]*>/g; |
| 33 | + return htmlRegex.test(value); |
| 34 | +}; |
0 commit comments