2020-11-17 11:16:34 +00:00
|
|
|
/**
|
|
|
|
* Check if an object is empty
|
|
|
|
* @param obj The object being checked
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* U.isEmpty({}) // => true
|
|
|
|
* U.isEmpty({ bob: true }) // => false
|
|
|
|
*/
|
2023-04-30 16:32:28 +00:00
|
|
|
export function isEmpty(obj: object): boolean {
|
2020-11-17 11:16:34 +00:00
|
|
|
// @ts-ignore
|
|
|
|
return [Object, Array].includes((obj || {}).constructor) && !Object.entries(obj || {}).length;
|
|
|
|
}
|