reordering the patch for #504

This commit is contained in:
Jeremy Ashkenas
2012-04-02 15:30:12 -04:00
parent 62114126d9
commit 4620eb7b61

View File

@@ -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.