1 | var apply = require('./_apply'),
|
2 | arrayMap = require('./_arrayMap'),
|
3 | baseFlatten = require('./_baseFlatten'),
|
4 | baseIteratee = require('./_baseIteratee'),
|
5 | baseRest = require('./_baseRest'),
|
6 | baseUnary = require('./_baseUnary'),
|
7 | castRest = require('./_castRest'),
|
8 | isArray = require('./isArray');
|
9 |
|
10 |
|
11 | var nativeMin = Math.min;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | var 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 |
|
61 | module.exports = overArgs;
|