mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-01 13:23:09 +00:00
16 lines
538 B
TypeScript
16 lines
538 B
TypeScript
/**
|
|
* Checks if a type is an object
|
|
* @param {any} candidate the entity to check
|
|
*/
|
|
const isObject = (candidate: any): candidate is object =>
|
|
candidate && Object.prototype.toString.call(candidate) === '[object Object]';
|
|
|
|
/**
|
|
* Checks that an object has it own enumerable props
|
|
* @param {any} object the object to the be tested
|
|
* @return {boolean} true if enumerable keys are present
|
|
*/
|
|
const hasEnumerableKeys = (object: any): boolean => isObject(object) && !!Object.keys(object).length;
|
|
|
|
export { isObject, hasEnumerableKeys };
|