CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
curry.js58 linesDownload Raw Back to lodash-es
1import createWrap from './_createWrap.js';2 3/** Used to compose bitmasks for function metadata. */4var WRAP_CURRY_FLAG = 8;5 6/**7 * Creates a function that accepts arguments of `func` and either invokes8 * `func` returning its result, if at least `arity` number of arguments have9 * been provided, or returns a function that accepts the remaining `func`10 * arguments, and so on. The arity of `func` may be specified if `func.length`11 * is not sufficient.12 *13 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,14 * may be used as a placeholder for provided arguments.15 *16 * **Note:** This method doesn't set the "length" property of curried functions.17 *18 * @static19 * @memberOf _20 * @since 2.0.021 * @category Function22 * @param {Function} func The function to curry.23 * @param {number} [arity=func.length] The arity of `func`.24 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.25 * @returns {Function} Returns the new curried function.26 * @example27 *28 * var abc = function(a, b, c) {29 *   return [a, b, c];30 * };31 *32 * var curried = _.curry(abc);33 *34 * curried(1)(2)(3);35 * // => [1, 2, 3]36 *37 * curried(1, 2)(3);38 * // => [1, 2, 3]39 *40 * curried(1, 2, 3);41 * // => [1, 2, 3]42 *43 * // Curried with placeholders.44 * curried(1)(_, 3)(2);45 * // => [1, 2, 3]46 */47function curry(func, arity, guard) {48  arity = guard ? undefined : arity;49  var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);50  result.placeholder = curry.placeholder;51  return result;52}53 54// Assign default placeholders.55curry.placeholder = {};56 57export default curry;58 
basant307/AI_Governance_Project · CoolFace