9286cc25f1bc07aaef0ea8149290b6b9c42a9392
[platform/framework/web/crosswalk-tizen.git] /
1 var invokePath = require('../internal/invokePath'),
2     restParam = require('../function/restParam');
3
4 /**
5  * The opposite of `_.method`; this method creates a function which invokes
6  * the method at a given path on `object`.
7  *
8  * @static
9  * @memberOf _
10  * @category Utility
11  * @param {Object} object The object to query.
12  * @returns {Function} Returns the new function.
13  * @example
14  *
15  * var array = _.times(3, _.constant),
16  *     object = { 'a': array, 'b': array, 'c': array };
17  *
18  * _.map(['a[2]', 'c[0]'], _.methodOf(object));
19  * // => [2, 0]
20  *
21  * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
22  * // => [2, 0]
23  */
24 var methodOf = restParam(function(object, args) {
25   return function(path) {
26     return invokePath(object, path, args);
27   };
28 });
29
30 module.exports = methodOf;