Sha256: ff8b9029e34108a24af2322c1bda2d2139e89464d25f436b0d18fa6e613a237e

Contents?: true

Size: 1.95 KB

Versions: 275

Compression:

Stored size: 1.95 KB

Contents

var baseKeys = require('./_baseKeys'),
    getTag = require('./_getTag'),
    isArguments = require('./isArguments'),
    isArray = require('./isArray'),
    isArrayLike = require('./isArrayLike'),
    isBuffer = require('./isBuffer'),
    isPrototype = require('./_isPrototype'),
    isTypedArray = require('./isTypedArray');

/** `Object#toString` result references. */
var mapTag = '[object Map]',
    setTag = '[object Set]';

/** Used for built-in method references. */
var objectProto = Object.prototype;

/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;

/**
 * Checks if `value` is an empty object, collection, map, or set.
 *
 * Objects are considered empty if they have no own enumerable string keyed
 * properties.
 *
 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
 * jQuery-like collections are considered empty if they have a `length` of `0`.
 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
 * @example
 *
 * _.isEmpty(null);
 * // => true
 *
 * _.isEmpty(true);
 * // => true
 *
 * _.isEmpty(1);
 * // => true
 *
 * _.isEmpty([1, 2, 3]);
 * // => false
 *
 * _.isEmpty({ 'a': 1 });
 * // => false
 */
function isEmpty(value) {
  if (value == null) {
    return true;
  }
  if (isArrayLike(value) &&
      (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
        isBuffer(value) || isTypedArray(value) || isArguments(value))) {
    return !value.length;
  }
  var tag = getTag(value);
  if (tag == mapTag || tag == setTag) {
    return !value.size;
  }
  if (isPrototype(value)) {
    return !baseKeys(value).length;
  }
  for (var key in value) {
    if (hasOwnProperty.call(value, key)) {
      return false;
    }
  }
  return true;
}

module.exports = isEmpty;

Version data entries

275 entries across 273 versions & 30 rubygems

Version Path
rapid_stack-0.1.1 templates/FrontEnd/node_modules/lodash/isEmpty.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.60 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.59 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.58 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.57 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.56 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.55 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.54 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.53 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.52 node_modules/lodash/isEmpty.js
trusty-cms-6.3.1 node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.51 node_modules/lodash/isEmpty.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/isEmpty.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/isEmpty.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/isEmpty.js
immosquare-cleaner-0.1.50 node_modules/lodash/isEmpty.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/isEmpty.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/isEmpty.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/isEmpty.js