UNPKG

@mi-gpt/utils

Version:
44 lines (42 loc) 1.23 kB
// src/is.ts function isNull(input) { return input === null; } function isUndefined(input) { return input === void 0; } function isNullish(input) { return input == null; } function isNotNullish(input) { return !isNullish(input); } function isEmpty(e) { if (((e == null ? void 0 : e.size) ?? 0) > 0) return false; return Number.isNaN(e) || isNullish(e) || isString(e) && (e.length < 1 || !/\S/.test(e)) || isArray(e) && e.length < 1 || isObject(e) && Object.keys(e).length < 1; } function isNotEmpty(e) { return !isEmpty(e); } function isNumber(input) { return typeof input === "number" && !Number.isNaN(input); } function isString(input) { return typeof input === "string"; } function isArray(input) { return Array.isArray(input); } function isObject(e) { return typeof e === "object" && isNotNullish(e); } function isFunction(e) { return typeof e === "function"; } function isClass(e) { return isFunction(e) && e.toString().startsWith("class "); } function isStringNumber(e) { return isString(e) && isNotEmpty(e) && !Number.isNaN(Number(e)); } export { isArray, isClass, isEmpty, isFunction, isNotEmpty, isNotNullish, isNull, isNullish, isNumber, isObject, isString, isStringNumber, isUndefined };