invoke.js 634 B

12345678910111213141516171819202122232425
  1. var baseInvoke = require('./_baseInvoke'),
  2. baseRest = require('./_baseRest');
  3. /**
  4. * Invokes the method at `path` of `object`.
  5. *
  6. * @static
  7. * @memberOf _
  8. * @since 4.0.0
  9. * @category Object
  10. * @param {Object} object The object to query.
  11. * @param {Array|string} path The path of the method to invoke.
  12. * @param {...*} [args] The arguments to invoke the method with.
  13. * @returns {*} Returns the result of the invoked method.
  14. * @example
  15. *
  16. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  17. *
  18. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  19. * // => [2, 3]
  20. */
  21. var invoke = baseRest(baseInvoke);
  22. module.exports = invoke;