Add support for maps and sets to _.size.

This commit is contained in:
John-David Dalton
2016-03-21 20:16:15 -07:00
parent 6d587bdf34
commit 25eb4df563
2 changed files with 34 additions and 0 deletions

View File

@@ -8572,6 +8572,12 @@
var result = collection.length;
return (result && isString(collection)) ? stringSize(collection) : result;
}
if (isObjectLike(collection)) {
var tag = getTag(collection);
if (tag == mapTag || tag == setTag) {
return collection.size;
}
}
return keys(collection).length;
}