topkat-utils
Version:
A comprehensive collection of TypeScript/JavaScript utility functions for common programming tasks. Includes validation, object manipulation, date handling, string formatting, and more. Zero dependencies, fully typed, and optimized for performance.
7 lines (5 loc) • 335 B
text/typescript
export function isEmpty(objOrArr: object | any[] | string | null | undefined) {
if (Array.isArray(objOrArr) || typeof objOrArr === 'string') return objOrArr.length === 0
else if (typeof objOrArr == 'object' && objOrArr !== null && !(objOrArr instanceof Date)) return Object.keys(objOrArr).length === 0
else return false
}