mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Bump to v4.15.0.
This commit is contained in:
14
size.js
14
size.js
@@ -1,7 +1,6 @@
|
||||
var baseKeys = require('./_baseKeys'),
|
||||
getTag = require('./_getTag'),
|
||||
isArrayLike = require('./isArrayLike'),
|
||||
isObjectLike = require('./isObjectLike'),
|
||||
isString = require('./isString'),
|
||||
stringSize = require('./_stringSize');
|
||||
|
||||
@@ -17,7 +16,7 @@ var mapTag = '[object Map]',
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Collection
|
||||
* @param {Array|Object} collection The collection to inspect.
|
||||
* @param {Array|Object|string} collection The collection to inspect.
|
||||
* @returns {number} Returns the collection size.
|
||||
* @example
|
||||
*
|
||||
@@ -35,14 +34,11 @@ function size(collection) {
|
||||
return 0;
|
||||
}
|
||||
if (isArrayLike(collection)) {
|
||||
var result = collection.length;
|
||||
return (result && isString(collection)) ? stringSize(collection) : result;
|
||||
return isString(collection) ? stringSize(collection) : collection.length;
|
||||
}
|
||||
if (isObjectLike(collection)) {
|
||||
var tag = getTag(collection);
|
||||
if (tag == mapTag || tag == setTag) {
|
||||
return collection.size;
|
||||
}
|
||||
var tag = getTag(collection);
|
||||
if (tag == mapTag || tag == setTag) {
|
||||
return collection.size;
|
||||
}
|
||||
return baseKeys(collection).length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user