mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Bump to v4.15.0.
This commit is contained in:
14
size.js
14
size.js
@@ -1,7 +1,6 @@
|
||||
import baseKeys from './_baseKeys.js';
|
||||
import getTag from './_getTag.js';
|
||||
import isArrayLike from './isArrayLike.js';
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
import isString from './isString.js';
|
||||
import stringSize from './_stringSize.js';
|
||||
|
||||
@@ -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