main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
858 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import baseInvoke from './_baseInvoke.js';
|
---|
| 2 | import baseRest from './_baseRest.js';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Creates a function that invokes the method at `path` of a given object.
|
---|
| 6 | * Any additional arguments are provided to the invoked method.
|
---|
| 7 | *
|
---|
| 8 | * @static
|
---|
| 9 | * @memberOf _
|
---|
| 10 | * @since 3.7.0
|
---|
| 11 | * @category Util
|
---|
| 12 | * @param {Array|string} path The path of the method to invoke.
|
---|
| 13 | * @param {...*} [args] The arguments to invoke the method with.
|
---|
| 14 | * @returns {Function} Returns the new invoker function.
|
---|
| 15 | * @example
|
---|
| 16 | *
|
---|
| 17 | * var objects = [
|
---|
| 18 | * { 'a': { 'b': _.constant(2) } },
|
---|
| 19 | * { 'a': { 'b': _.constant(1) } }
|
---|
| 20 | * ];
|
---|
| 21 | *
|
---|
| 22 | * _.map(objects, _.method('a.b'));
|
---|
| 23 | * // => [2, 1]
|
---|
| 24 | *
|
---|
| 25 | * _.map(objects, _.method(['a', 'b']));
|
---|
| 26 | * // => [2, 1]
|
---|
| 27 | */
|
---|
| 28 | var method = baseRest(function(path, args) {
|
---|
| 29 | return function(object) {
|
---|
| 30 | return baseInvoke(object, path, args);
|
---|
| 31 | };
|
---|
| 32 | });
|
---|
| 33 |
|
---|
| 34 | export default method;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.