Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / globule / node_modules / lodash / _baseInvoke.js
1 var apply = require('./_apply'),
2     castPath = require('./_castPath'),
3     isKey = require('./_isKey'),
4     last = require('./last'),
5     parent = require('./_parent'),
6     toKey = require('./_toKey');
7
8 /**
9  * The base implementation of `_.invoke` without support for individual
10  * method arguments.
11  *
12  * @private
13  * @param {Object} object The object to query.
14  * @param {Array|string} path The path of the method to invoke.
15  * @param {Array} args The arguments to invoke the method with.
16  * @returns {*} Returns the result of the invoked method.
17  */
18 function baseInvoke(object, path, args) {
19   if (!isKey(path, object)) {
20     path = castPath(path);
21     object = parent(object, path);
22     path = last(path);
23   }
24   var func = object == null ? object : object[toKey(path)];
25   return func == null ? undefined : apply(func, object, args);
26 }
27
28 module.exports = baseInvoke;