'_.toArray' now checks whether the iterable object contains a 'toArray' method to delegate to.

This commit is contained in:
matehat
2009-11-21 22:02:31 -05:00
parent ae968a6ea0
commit 3c0b7125a7

View File

@@ -217,6 +217,7 @@
// Convert anything iterable into a real, live array.
_.toArray = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
if (_.isArray(iterable)) return iterable;
return _.map(iterable, function(val){ return val; });
};