CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
isEmpty.js78 linesDownload Raw Back to lodash
1var baseKeys = require('./_baseKeys'),2    getTag = require('./_getTag'),3    isArguments = require('./isArguments'),4    isArray = require('./isArray'),5    isArrayLike = require('./isArrayLike'),6    isBuffer = require('./isBuffer'),7    isPrototype = require('./_isPrototype'),8    isTypedArray = require('./isTypedArray');9 10/** `Object#toString` result references. */11var mapTag = '[object Map]',12    setTag = '[object Set]';13 14/** Used for built-in method references. */15var objectProto = Object.prototype;16 17/** Used to check objects for own properties. */18var hasOwnProperty = objectProto.hasOwnProperty;19 20/**21 * Checks if `value` is an empty object, collection, map, or set.22 *23 * Objects are considered empty if they have no own enumerable string keyed24 * properties.25 *26 * Array-like values such as `arguments` objects, arrays, buffers, strings, or27 * jQuery-like collections are considered empty if they have a `length` of `0`.28 * Similarly, maps and sets are considered empty if they have a `size` of `0`.29 *30 * @static31 * @memberOf _32 * @since 0.1.033 * @category Lang34 * @param {*} value The value to check.35 * @returns {boolean} Returns `true` if `value` is empty, else `false`.36 * @example37 *38 * _.isEmpty(null);39 * // => true40 *41 * _.isEmpty(true);42 * // => true43 *44 * _.isEmpty(1);45 * // => true46 *47 * _.isEmpty([1, 2, 3]);48 * // => false49 *50 * _.isEmpty({ 'a': 1 });51 * // => false52 */53function isEmpty(value) {54  if (value == null) {55    return true;56  }57  if (isArrayLike(value) &&58      (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||59        isBuffer(value) || isTypedArray(value) || isArguments(value))) {60    return !value.length;61  }62  var tag = getTag(value);63  if (tag == mapTag || tag == setTag) {64    return !value.size;65  }66  if (isPrototype(value)) {67    return !baseKeys(value).length;68  }69  for (var key in value) {70    if (hasOwnProperty.call(value, key)) {71      return false;72    }73  }74  return true;75}76 77module.exports = isEmpty;78 
basant307/AI_Governance_Project · CoolFace