UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

34 lines (25 loc) 634 B
import isObject from './is_object.js'; import './get_tag.js'; import isArray from './is_array.js'; import isString from './is_string.js'; import isMap from './is_map.js'; import isSet from './is_set.js'; function isEmpty(obj) { if (obj === null) { return true; } if (isArray(obj)) { return !obj.length; } if (isString(obj)) { return !obj.length; } if (isObject(obj)) { return !Object.keys(obj).length; } if (isMap(obj) || isSet(obj)) { return !obj.size; } // other primitive || unidentifed object type return Object(obj) !== obj || !Object.keys(obj).length; } export default isEmpty;