time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

unary.js (469B)


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