UNPKG

@amxdev/is-empty

Version:

Utility to check if a value is empty (null, undefined, string, array, or object)

15 lines (11 loc) 295 B
// src/index.ts export function isEmpty(value: any): boolean { if (value == null) return true; if (typeof value === "string" || Array.isArray(value)) { return value.length === 0; } if (typeof value === "object") { return Object.keys(value).length === 0; } return false; }