UNPKG

lenye_base

Version:

基础方法

34 lines (25 loc) 634 B
import './get_tag.js'; import isArray from './is_array.js'; import isObject from './is_object.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;