@storm-stack/types
Version:
⚡ The storm-stack monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.
28 lines (27 loc) • 932 B
JavaScript
import { isDate } from "./is-date.mjs";
import { isFunction } from "./is-function.mjs";
import { isNull } from "./is-null.mjs";
import { isNumber } from "./is-number.mjs";
import { isSymbol } from "./is-symbol.mjs";
import { isUndefined } from "./is-undefined.mjs";
export const isEmpty = (value) => {
try {
return isUndefined(value) || isNull(value);
} catch {
return false;
}
};
export const isEmptyAnything = (value) => {
if (value === true || value === false) return true;
if (value === null || value === void 0) return true;
if (isNumber(value)) return value === 0;
if (isDate(value)) return Number.isNaN(value.getTime());
if (isFunction(value)) return false;
if (isSymbol(value)) return false;
const { length } = value;
if (isNumber(length)) return length === 0;
const { size } = value;
if (isNumber(size)) return size === 0;
const keys = Object.keys(value).length;
return keys === 0;
};