1 var getLength = require('../internal/getLength'),
2 isLength = require('../internal/isLength'),
3 keys = require('../object/keys');
6 * Gets the size of `collection` by returning its length for array-like
7 * values or the number of own enumerable properties for objects.
11 * @category Collection
12 * @param {Array|Object|string} collection The collection to inspect.
13 * @returns {number} Returns the size of `collection`.
19 * _.size({ 'a': 1, 'b': 2 });
25 function size(collection) {
26 var length = collection ? getLength(collection) : 0;
27 return isLength(length) ? length : keys(collection).length;
30 module.exports = size;