UNPKG

diginext-utils

Version:
31 lines 742 B
/** * Checks if a value is empty (null, undefined, empty string, empty array, empty object, or falsy). * * @param value - The value to check * @returns True if the value is empty * * @example * ```ts * isEmpty(null); // true * isEmpty(undefined); // true * isEmpty(''); // true * isEmpty([]); // true * isEmpty({}); // true * isEmpty(false); // true * isEmpty(0); // true * isEmpty('hello'); // false * ``` */ export function isEmpty(value) { if (!value) { return true; } if (Array.isArray(value)) { return value.length === 0; } if (typeof value === "object" && value !== null) { return Object.keys(value).length === 0; } return false; } //# sourceMappingURL=isEmpty.js.map