Sha256: f79439ffd5760d5a465dd33f8e4bcc6fe73e06f52a3a10cd88db93e9694e5ddc

Contents?: true

Size: 761 Bytes

Versions: 153

Compression:

Stored size: 761 Bytes

Contents

var getLength = require('../internal/getLength'),
    isLength = require('../internal/isLength'),
    keys = require('../object/keys');

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

module.exports = size;

Version data entries

153 entries across 80 versions & 8 rubygems

Version Path
ilog-0.4.1 node_modules/contents/node_modules/lodash/collection/size.js
ilog-0.4.1 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/collection/size.js
ilog-0.4.1 node_modules/babel/node_modules/lodash/collection/size.js
ilog-0.4.0 node_modules/babel/node_modules/lodash/collection/size.js
ilog-0.4.0 node_modules/contents/node_modules/lodash/collection/size.js
ilog-0.4.0 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/collection/size.js
ilog-0.3.3 node_modules/babel/node_modules/lodash/collection/size.js
ilog-0.3.3 node_modules/contents/node_modules/lodash/collection/size.js
ilog-0.3.3 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/inquirer/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/inquirer/node_modules/lodash/collection/size.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/collection/size.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/inquirer/node_modules/lodash/collection/size.js