[d565449] | 1 | /* Built-in method references for those with the same name as other `lodash` methods. */
|
---|
| 2 | var nativeMax = Math.max;
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * This function is like `composeArgs` except that the arguments composition
|
---|
| 6 | * is tailored for `_.partialRight`.
|
---|
| 7 | *
|
---|
| 8 | * @private
|
---|
| 9 | * @param {Array} args The provided arguments.
|
---|
| 10 | * @param {Array} partials The arguments to append to those provided.
|
---|
| 11 | * @param {Array} holders The `partials` placeholder indexes.
|
---|
| 12 | * @params {boolean} [isCurried] Specify composing for a curried function.
|
---|
| 13 | * @returns {Array} Returns the new array of composed arguments.
|
---|
| 14 | */
|
---|
| 15 | function composeArgsRight(args, partials, holders, isCurried) {
|
---|
| 16 | var argsIndex = -1,
|
---|
| 17 | argsLength = args.length,
|
---|
| 18 | holdersIndex = -1,
|
---|
| 19 | holdersLength = holders.length,
|
---|
| 20 | rightIndex = -1,
|
---|
| 21 | rightLength = partials.length,
|
---|
| 22 | rangeLength = nativeMax(argsLength - holdersLength, 0),
|
---|
| 23 | result = Array(rangeLength + rightLength),
|
---|
| 24 | isUncurried = !isCurried;
|
---|
| 25 |
|
---|
| 26 | while (++argsIndex < rangeLength) {
|
---|
| 27 | result[argsIndex] = args[argsIndex];
|
---|
| 28 | }
|
---|
| 29 | var offset = argsIndex;
|
---|
| 30 | while (++rightIndex < rightLength) {
|
---|
| 31 | result[offset + rightIndex] = partials[rightIndex];
|
---|
| 32 | }
|
---|
| 33 | while (++holdersIndex < holdersLength) {
|
---|
| 34 | if (isUncurried || argsIndex < argsLength) {
|
---|
| 35 | result[offset + holders[holdersIndex]] = args[argsIndex++];
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | return result;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | export default composeArgsRight;
|
---|