Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / utility / method.js
1 var invokePath = require('../internal/invokePath'),
2     restParam = require('../function/restParam');
3
4 /**
5  * Creates a function that invokes the method at `path` on a given object.
6  * Any additional arguments are provided to the invoked method.
7  *
8  * @static
9  * @memberOf _
10  * @category Utility
11  * @param {Array|string} path The path of the method to invoke.
12  * @param {...*} [args] The arguments to invoke the method with.
13  * @returns {Function} Returns the new function.
14  * @example
15  *
16  * var objects = [
17  *   { 'a': { 'b': { 'c': _.constant(2) } } },
18  *   { 'a': { 'b': { 'c': _.constant(1) } } }
19  * ];
20  *
21  * _.map(objects, _.method('a.b.c'));
22  * // => [2, 1]
23  *
24  * _.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c');
25  * // => [1, 2]
26  */
27 var method = restParam(function(path, args) {
28   return function(object) {
29     return invokePath(object, path, args);
30   };
31 });
32
33 module.exports = method;