lodash: Ensure max and min do not error when computing the result of massive arrays. [cederberg, jddalton, jeeyoungk]

Former-commit-id: af982790c3bb62777523f972a95b7115fb645180
This commit is contained in:
John-David Dalton
2012-05-06 19:38:15 -04:00
parent d26fc7154c
commit 52cf17b24a
4 changed files with 114 additions and 92 deletions

View File

@@ -139,8 +139,9 @@
'top':
'var current, computed = -Infinity, result = computed;\n' +
'if (!callback) {\n' +
'if (isArray(collection) && collection[0] === +collection[0])' +
'return Math.max.apply(Math, collection);\n' +
'if (isArray(collection) && collection[0] === +collection[0]) {\n' +
'try { return Math.max.apply(Math, collection); } catch(e) { }\n' +
'}\n' +
'if (isEmpty(collection))' +
'return result\n' +
'} else if (thisArg) callback = bind(callback, thisArg)',