Bump to v3.6.0.

This commit is contained in:
jdalton
2015-03-24 16:44:49 -07:00
parent 06f6ffa303
commit d58549ce0b
192 changed files with 2218 additions and 1804 deletions

View File

@@ -1,5 +1,6 @@
var baseInvoke = require('../internal/baseInvoke'),
baseSlice = require('../internal/baseSlice');
var baseEach = require('../internal/baseEach'),
isLength = require('../internal/isLength'),
restParam = require('../function/restParam');
/**
* Invokes the method named by `methodName` on each element in `collection`,
@@ -23,8 +24,17 @@ var baseInvoke = require('../internal/baseInvoke'),
* _.invoke([123, 456], String.prototype.split, '');
* // => [['1', '2', '3'], ['4', '5', '6']]
*/
function invoke(collection, methodName) {
return baseInvoke(collection, methodName, baseSlice(arguments, 2));
}
var invoke = restParam(function(collection, methodName, args) {
var index = -1,
isFunc = typeof methodName == 'function',
length = collection ? collection.length : 0,
result = isLength(length) ? Array(length) : [];
baseEach(collection, function(value) {
var func = isFunc ? methodName : (value != null && value[methodName]);
result[++index] = func ? func.apply(value, args) : undefined;
});
return result;
});
module.exports = invoke;