mirror of
https://github.com/nocobase/nocobase
synced 2024-11-17 06:36:28 +00:00
19 lines
459 B
TypeScript
19 lines
459 B
TypeScript
|
export const isEmpty = (value: unknown) => {
|
||
|
if (isPlainObject(value)) {
|
||
|
return Object.keys(value).length === 0;
|
||
|
}
|
||
|
if (Array.isArray(value)) {
|
||
|
return value.length === 0;
|
||
|
}
|
||
|
return !value;
|
||
|
};
|
||
|
|
||
|
export const isPlainObject = (value) => {
|
||
|
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
const prototype = Object.getPrototypeOf(value);
|
||
|
return prototype === null || prototype === Object.prototype;
|
||
|
};
|