Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / invokePath.js
1 var baseGet = require('./baseGet'),
2     baseSlice = require('./baseSlice'),
3     isKey = require('./isKey'),
4     last = require('../array/last'),
5     toPath = require('./toPath');
6
7 /**
8  * Invokes the method at `path` on `object`.
9  *
10  * @private
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.
15  */
16 function invokePath(object, path, args) {
17   if (object != null && !isKey(path, object)) {
18     path = toPath(path);
19     object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
20     path = last(path);
21   }
22   var func = object == null ? object : object[path];
23   return func == null ? undefined : func.apply(object, args);
24 }
25
26 module.exports = invokePath;