You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
789 B

преди 3 години
  1. var apply = require('./_apply'),
  2. castPath = require('./_castPath'),
  3. last = require('./last'),
  4. parent = require('./_parent'),
  5. toKey = require('./_toKey');
  6. /**
  7. * The base implementation of `_.invoke` without support for individual
  8. * method arguments.
  9. *
  10. * @private
  11. * @param {Object} object The object to query.
  12. * @param {Array|string} path The path of the method to invoke.
  13. * @param {Array} args The arguments to invoke the method with.
  14. * @returns {*} Returns the result of the invoked method.
  15. */
  16. function baseInvoke(object, path, args) {
  17. path = castPath(path, object);
  18. object = parent(object, path);
  19. var func = object == null ? object : object[toKey(last(path))];
  20. return func == null ? undefined : apply(func, object, args);
  21. }
  22. module.exports = baseInvoke;