@cloudcome/utils-core
Version:
cloudcome core utils
33 lines (32 loc) • 1.09 kB
TypeScript
import { AnyObject } from '../types';
/**
* 检查一个对象是否为空对象(不包含任何自有属性,包括符号属性)。
*
* @param obj - 要检查的对象
* @returns 如果对象没有自有属性(包括符号属性)则返回 true,否则返回 false
*
* @example
* ```typescript
* isEmptyObject({}); // true
* isEmptyObject({ a: 1 }); // false
* isEmptyObject(Object.create(null)); // true
* isEmptyObject({ [Symbol('key')]: 'value' }); // false
* ```
*/
export declare function isEmptyObject(obj: AnyObject): boolean;
/**
* 检查一个对象是否为纯对象(通过对象字面量或Object构造函数创建,而非其他构造函数的实例)。
*
* @param obj - 要检查的对象
* @returns 如果是纯对象则返回 true,否则返回 false
*
* @example
* ```typescript
* isPlainObject({}); // true
* isPlainObject(Object.create(null)); // true
* isPlainObject(new Date()); // false
* isPlainObject([]); // false
* isPlainObject(() => {}); // false
* ```
*/
export declare function isPlainObject(obj: AnyObject): boolean;