Sha256: f364a213efbd423be9914f35913e4d9a4b19b35a6a63f2e8043ba99b2dbd447d

Contents?: true

Size: 1.11 KB

Versions: 265

Compression:

Stored size: 1.11 KB

Contents

var baseKeys = require('./_baseKeys'),
    getTag = require('./_getTag'),
    isArrayLike = require('./isArrayLike'),
    isString = require('./isString'),
    stringSize = require('./_stringSize');

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

/**
 * Gets the size of `collection` by returning its length for array-like
 * values or the number of own enumerable string keyed properties for objects.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Collection
 * @param {Array|Object|string} collection The collection to inspect.
 * @returns {number} Returns the collection size.
 * @example
 *
 * _.size([1, 2, 3]);
 * // => 3
 *
 * _.size({ 'a': 1, 'b': 2 });
 * // => 2
 *
 * _.size('pebbles');
 * // => 7
 */
function size(collection) {
  if (collection == null) {
    return 0;
  }
  if (isArrayLike(collection)) {
    return isString(collection) ? stringSize(collection) : collection.length;
  }
  var tag = getTag(collection);
  if (tag == mapTag || tag == setTag) {
    return collection.size;
  }
  return baseKeys(collection).length;
}

module.exports = size;

Version data entries

265 entries across 263 versions & 30 rubygems

Version Path
trusty-cms-6.3.1 node_modules/lodash/size.js
immosquare-cleaner-0.1.51 node_modules/lodash/size.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/size.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/size.js
immosquare-cleaner-0.1.50 node_modules/lodash/size.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/lodash/size.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/lodash/size.js
immosquare-cleaner-0.1.49 node_modules/lodash/size.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/lodash/size.js
immosquare-cleaner-0.1.48 node_modules/lodash/size.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/lodash/size.js