CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
overArgs.js62 linesDownload Raw Back to lodash-es
1import apply from './_apply.js';2import arrayMap from './_arrayMap.js';3import baseFlatten from './_baseFlatten.js';4import baseIteratee from './_baseIteratee.js';5import baseRest from './_baseRest.js';6import baseUnary from './_baseUnary.js';7import castRest from './_castRest.js';8import isArray from './isArray.js';9 10/* Built-in method references for those with the same name as other `lodash` methods. */11var nativeMin = Math.min;12 13/**14 * Creates a function that invokes `func` with its arguments transformed.15 *16 * @static17 * @since 4.0.018 * @memberOf _19 * @category Function20 * @param {Function} func The function to wrap.21 * @param {...(Function|Function[])} [transforms=[_.identity]]22 *  The argument transforms.23 * @returns {Function} Returns the new function.24 * @example25 *26 * function doubled(n) {27 *   return n * 2;28 * }29 *30 * function square(n) {31 *   return n * n;32 * }33 *34 * var func = _.overArgs(function(x, y) {35 *   return [x, y];36 * }, [square, doubled]);37 *38 * func(9, 3);39 * // => [81, 6]40 *41 * func(10, 5);42 * // => [100, 10]43 */44var overArgs = castRest(function(func, transforms) {45  transforms = (transforms.length == 1 && isArray(transforms[0]))46    ? arrayMap(transforms[0], baseUnary(baseIteratee))47    : arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee));48 49  var funcsLength = transforms.length;50  return baseRest(function(args) {51    var index = -1,52        length = nativeMin(args.length, funcsLength);53 54    while (++index < length) {55      args[index] = transforms[index].call(this, args[index]);56    }57    return apply(func, this, args);58  });59});60 61export default overArgs;62 
basant307/AI_Governance_Project · CoolFace