Merge pull request #504 from mwilliamson/master

Don't call iterable.toArray in _.toArray if not a function
This commit is contained in:
Jeremy Ashkenas
2012-04-02 12:27:38 -07:00
2 changed files with 11 additions and 3 deletions

View File

@@ -304,7 +304,7 @@
// Safely convert anything iterable into a real, live array.
_.toArray = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
if (iterable.toArray && _.isFunction(iterable.toArray)) return iterable.toArray();
if (_.isArray(iterable)) return slice.call(iterable);
if (_.isArguments(iterable)) return slice.call(iterable);
return _.values(iterable);