Expose _.invokePath.

This commit is contained in:
John-David Dalton
2015-11-21 21:57:54 -08:00
parent 73a97d5762
commit 87a813566a
2 changed files with 23 additions and 20 deletions

View File

@@ -4780,25 +4780,6 @@
: null;
}
/**
* Invokes the method at `path` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the method to invoke.
* @param {Array} args The arguments to invoke the method with.
* @returns {*} Returns the result of the invoked method.
*/
function invokePath(object, path, args) {
if (!isKey(path, object)) {
path = baseToPath(path);
object = parent(object, path);
path = last(path);
}
var func = object == null ? object : object[path];
return func == null ? undefined : func.apply(object, args);
}
/**
* Checks if the provided arguments are from an iteratee call.
*
@@ -10895,6 +10876,27 @@
}, {});
}
/**
* Invokes the method at `path` of `object`.
*
* @static
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the method to invoke.
* @param {Array} args The arguments to invoke the method with.
* @returns {*} Returns the result of the invoked method.
*/
function invokePath(object, path, args) {
if (!isKey(path, object)) {
path = baseToPath(path);
object = parent(object, path);
path = last(path);
}
var func = object == null ? object : object[path];
return func == null ? undefined : func.apply(object, args);
}
/**
* Creates an array of the own enumerable property names of `object`.
*
@@ -13705,6 +13707,7 @@
lodash.intersectionWith = intersectionWith;
lodash.invert = invert;
lodash.invoke = invoke;
lodash.invokePath = invokePath;
lodash.iteratee = iteratee;
lodash.keyBy = keyBy;
lodash.keys = keys;

View File

@@ -22595,7 +22595,7 @@
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
QUnit.test('should accept falsey arguments', function(assert) {
assert.expect(281);
assert.expect(282);
var emptyArrays = lodashStable.map(falsey, lodashStable.constant([]));