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