From 87a813566a09d41283f42db84513c1ef91ec5e5b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 21 Nov 2015 21:57:54 -0800 Subject: [PATCH] Expose `_.invokePath`. --- lodash.js | 41 ++++++++++++++++++++++------------------- test/test.js | 2 +- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/lodash.js b/lodash.js index bedd53c5f..ccd31cde2 100644 --- a/lodash.js +++ b/lodash.js @@ -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; diff --git a/test/test.js b/test/test.js index c529e7480..839e272f1 100644 --- a/test/test.js +++ b/test/test.js @@ -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([]));