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.

28 lines
636 B

4 years ago
  1. var createWrap = require('./_createWrap');
  2. /** Used to compose bitmasks for function metadata. */
  3. var WRAP_FLIP_FLAG = 512;
  4. /**
  5. * Creates a function that invokes `func` with arguments reversed.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 4.0.0
  10. * @category Function
  11. * @param {Function} func The function to flip arguments for.
  12. * @returns {Function} Returns the new flipped function.
  13. * @example
  14. *
  15. * var flipped = _.flip(function() {
  16. * return _.toArray(arguments);
  17. * });
  18. *
  19. * flipped('a', 'b', 'c', 'd');
  20. * // => ['d', 'c', 'b', 'a']
  21. */
  22. function flip(func) {
  23. return createWrap(func, WRAP_FLIP_FLAG);
  24. }
  25. module.exports = flip;