flip.js 636 B

1234567891011121314151617181920212223242526272829
  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;