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.

22 lines
469 B

4 years ago
  1. var ary = require('./ary');
  2. /**
  3. * Creates a function that accepts up to one argument, ignoring any
  4. * additional arguments.
  5. *
  6. * @static
  7. * @memberOf _
  8. * @since 4.0.0
  9. * @category Function
  10. * @param {Function} func The function to cap arguments for.
  11. * @returns {Function} Returns the new capped function.
  12. * @example
  13. *
  14. * _.map(['6', '8', '10'], _.unary(parseInt));
  15. * // => [6, 8, 10]
  16. */
  17. function unary(func) {
  18. return ary(func, 1);
  19. }
  20. module.exports = unary;