mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
'_.toArray' now checks whether the iterable object contains a 'toArray' method to delegate to.
This commit is contained in:
@@ -217,6 +217,7 @@
|
|||||||
// Convert anything iterable into a real, live array.
|
// Convert anything iterable into a real, live array.
|
||||||
_.toArray = function(iterable) {
|
_.toArray = function(iterable) {
|
||||||
if (!iterable) return [];
|
if (!iterable) return [];
|
||||||
|
if (iterable.toArray) return iterable.toArray();
|
||||||
if (_.isArray(iterable)) return iterable;
|
if (_.isArray(iterable)) return iterable;
|
||||||
return _.map(iterable, function(val){ return val; });
|
return _.map(iterable, function(val){ return val; });
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user