UNPKG

diginext-utils

Version:
44 lines 1.09 kB
/** * Checks if a value is null, undefined, empty string, empty array, or empty object. * File instances are never considered null. * * @param value - The value to check * @returns True if the value is considered null/empty * * @example * ```ts * isNull(null); // true * isNull(undefined); // true * isNull(''); // true * isNull([]); // true * isNull({}); // true * isNull(0); // false * isNull('hello'); // false * isNull([1, 2]); // false * ``` */ export function isNull(value) { // Check if it's a File object (browser environment) try { if (value instanceof File) { return false; } } catch (_a) { // File might not be defined in Node environment } if (value === undefined || value === null) { return true; } 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=isNull.js.map