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