mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Merge pull request #504 from mwilliamson/master
Don't call iterable.toArray in _.toArray if not a function
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user