Deopt _.invoke.

This commit is contained in:
John-David Dalton
2014-03-06 00:45:01 -08:00
parent c6de1ab56c
commit f2f57dc5a5

View File

@@ -4147,22 +4147,15 @@
* // => [['1', '2', '3'], ['4', '5', '6']]
*/
function invoke(collection, methodName) {
var index = -1,
var args = slice(arguments, 2),
index = -1,
isFunc = typeof methodName == 'function',
length = collection ? collection.length : 0,
result = Array(typeof length == 'number' ? length : 0);
if (arguments.length < 3 && isArray(collection)) {
while (++index < length) {
var value = collection[index];
result[index] = isFunc ? methodName.call(value) : value[methodName]();
}
} else {
var args = slice(arguments, 2);
baseEach(collection, function(value) {
result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args);
});
}
baseEach(collection, function(value) {
result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args);
});
return result;
}