1 var baseGet = require('./baseGet'),
2 baseSlice = require('./baseSlice'),
3 isKey = require('./isKey'),
4 last = require('../array/last'),
5 toPath = require('./toPath');
8 * Invokes the method at `path` on `object`.
11 * @param {Object} object The object to query.
12 * @param {Array|string} path The path of the method to invoke.
13 * @param {Array} args The arguments to invoke the method with.
14 * @returns {*} Returns the result of the invoked method.
16 function invokePath(object, path, args) {
17 if (object != null && !isKey(path, object)) {
19 object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
22 var func = object == null ? object : object[path];
23 return func == null ? undefined : func.apply(object, args);
26 module.exports = invokePath;