mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
reordering the patch for #504
This commit is contained in:
@@ -302,12 +302,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Safely convert anything iterable into a real, live array.
|
// Safely convert anything iterable into a real, live array.
|
||||||
_.toArray = function(iterable) {
|
_.toArray = function(obj) {
|
||||||
if (!iterable) return [];
|
if (!obj) return [];
|
||||||
if (iterable.toArray && _.isFunction(iterable.toArray)) return iterable.toArray();
|
if (_.isArray(obj)) return slice.call(obj);
|
||||||
if (_.isArray(iterable)) return slice.call(iterable);
|
if (_.isArguments(obj)) return slice.call(obj);
|
||||||
if (_.isArguments(iterable)) return slice.call(iterable);
|
if (obj.toArray && _.isFunction(obj.toArray)) return obj.toArray();
|
||||||
return _.values(iterable);
|
return _.values(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the number of elements in an object.
|
// Return the number of elements in an object.
|
||||||
|
|||||||
Reference in New Issue
Block a user