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.

unary.js 469B

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