mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
_.size ludicrous speed improvement
This commit is contained in:
@@ -309,7 +309,11 @@
|
||||
|
||||
// Return the number of elements in an object.
|
||||
_.size = function(obj) {
|
||||
return _.toArray(obj).length;
|
||||
if (_.isArray(obj)) {
|
||||
return obj.length;
|
||||
} else {
|
||||
return _.keys(obj).length;
|
||||
}
|
||||
};
|
||||
|
||||
// Array Functions
|
||||
|
||||
Reference in New Issue
Block a user