merged matehat's toArray patch

This commit is contained in:
Jeremy Ashkenas
2009-11-22 00:50:08 -05:00
parent 3c0b7125a7
commit 67f1e8a9c8
2 changed files with 12 additions and 12 deletions

View File

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