13 lines
330 B
TypeScript
13 lines
330 B
TypeScript
/**
|
|
* Check if an object is empty
|
|
* @param obj The object being checked
|
|
*
|
|
* @example
|
|
* U.isEmpty({}) // => true
|
|
* U.isEmpty({ bob: true }) // => false
|
|
*/
|
|
export function isEmpty(obj: object): boolean {
|
|
// @ts-ignore
|
|
return [Object, Array].includes((obj || {}).constructor) && !Object.entries(obj || {}).length;
|
|
}
|