mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Deopt _.invoke.
This commit is contained in:
17
lodash.js
17
lodash.js
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user