add after ary assign assignIn assignInWith assignWith at before bind bindAll bindKey camelCase capitalize castArray ceil chain chunk clamp clone cloneDeep cloneDeepWith cloneWith compact concat conformsTo countBy create curry curryRight debounce deburr defaults defaultsDeep defer delay difference divide drop dropRight each eachRight endsWith entries entriesIn eq escape every extend extendWith fill filter find findIndex findKey findLast findLastIndex findLastKey first flatMap flatMapDeep flatMapDepth flatten flattenDeep flattenDepth flip floor forEach forEachRight forIn forInRight forOwn forOwnRight fromPairs functions functionsIn get groupBy gt gte has hasIn head inRange includes indexOf initial intersection invert invertBy invoke invokeMap isArguments isArray isArrayBuffer isArrayLike isArrayLikeObject isBoolean isBuffer isDate isElement isEmpty isEqual isEqualWith isError isFinite isFunction isInteger isLength isMap isMatch isMatchWith isNaN isNative isNil isNull isNumber isObject isObjectLike isPlainObject isRegExp isSafeInteger isSet isString isSymbol isTypedArray isUndefined isWeakMap isWeakSet join kebabCase keyBy keys keysIn last lastIndexOf lowerCase lowerFirst lt lte map mapKeys mapValues max maxBy mean meanBy memoize merge mergeWith min minBy multiply negate nth omit omitBy once orderBy overArgs pad padEnd padStart parseInt partial partialRight partition pick pickBy pull pullAll pullAllBy pullAllWith pullAt random rearg reduce reduceRight reject remove repeat replace rest result reverse round sample sampleSize set setWith shuffle size slice snakeCase some sortBy sortedIndex sortedIndexOf sortedLastIndex sortedLastIndexOf sortedUniq split spread startCase startsWith subtract sum sumBy tail take takeRight tap template throttle thru toArray toFinite toInteger toLength toLower toNumber toPairs toPairsIn toPlainObject toSafeInteger toString toUpper transform trim trimEnd trimStart truncate unary unescape union uniq uniqBy uniqWith unset unzip unzipWith update updateWith upperCase upperFirst values valuesIn without words wrap wrapperAt wrapperChain wrapperCommit wrapperFlatMap wrapperLodash wrapperNext wrapperPlant wrapperReverse wrapperToIterator wrapperValue xor zip zipObject zipObjectDeep zipWith

Lodash _.wrapperAt


The lodash _.wrapperAt method creates a new function that allows for partial application of arguments and specifies the indexes of the arguments to be wrapped. This can be useful for creating functions that apply a specific argument at a specific index, while allowing for other arguments to vary.

The _.wrapperAt method takes two arguments: the function to wrap and the indexes of the arguments to wrap. It returns a new function that, when called, will apply the specified arguments at the specified indexes, and pass any remaining arguments through to the wrapped function.

For example, consider the following function:

function sum(a, b, c) {
  return a + b + c;

We can use _.wrapperAt to create a new function that always applies b and c at indexes 1 and 2, respectively:

const sumPartial = _.wrapperAt(sum, [1, 2]);
console.log(sumPartial(10, 20)); // Output: NaN
console.log(sumPartial(10, 20, 30)); // Output: 60

In this example, sumPartial is a new function that applies 20 to the second index and 30 to the third index, with 10 being passed as the first argument. Calling sumPartial(10, 20) applies 20 to the second index of sum, but there is no value for the third index, so the function returns NaN. Calling sumPartial(10, 20, 30) applies both 20 and 30 to their respective indexes, and sum returns the expected value of 60.

Overall, _.wrapperAt can be a powerful tool for creating custom functions that allow for flexibility in argument passing, while still preserving some specificity around which arguments are applied at which indexes.