Projekt

Obecné

Profil

Stáhnout (1.29 KB) Statistiky
| Větev: | Revize:
1
/* Built-in method references for those with the same name as other `lodash` methods. */
2
var nativeMax = Math.max;
3

    
4
/**
5
 * Creates an array that is the composition of partially applied arguments,
6
 * placeholders, and provided arguments into a single array of arguments.
7
 *
8
 * @private
9
 * @param {Array} args The provided arguments.
10
 * @param {Array} partials The arguments to prepend 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 composeArgs(args, partials, holders, isCurried) {
16
  var argsIndex = -1,
17
      argsLength = args.length,
18
      holdersLength = holders.length,
19
      leftIndex = -1,
20
      leftLength = partials.length,
21
      rangeLength = nativeMax(argsLength - holdersLength, 0),
22
      result = Array(leftLength + rangeLength),
23
      isUncurried = !isCurried;
24

    
25
  while (++leftIndex < leftLength) {
26
    result[leftIndex] = partials[leftIndex];
27
  }
28
  while (++argsIndex < holdersLength) {
29
    if (isUncurried || argsIndex < argsLength) {
30
      result[holders[argsIndex]] = args[argsIndex];
31
    }
32
  }
33
  while (rangeLength--) {
34
    result[leftIndex++] = args[argsIndex++];
35
  }
36
  return result;
37
}
38

    
39
module.exports = composeArgs;
(150-150/590)