2017-09-27 09:33:20 -07:00
|
|
|
/**
|
|
|
|
* 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
|
2017-12-11 13:13:34 -08:00
|
|
|
* @param {any} object the object to the be tested
|
2017-09-27 09:33:20 -07:00
|
|
|
* @return {boolean} true if enumerable keys are present
|
|
|
|
*/
|
2017-12-11 13:13:34 -08:00
|
|
|
const hasEnumerableKeys = (object: any): boolean => isObject(object) && !!Object.keys(object).length;
|
2017-09-27 09:33:20 -07:00
|
|
|
|
|
|
|
export { isObject, hasEnumerableKeys };
|