root / HServer / 00.Server / 00.Program / node_modules / lodash / zipWith.js
이력 | 보기 | 이력해설 | 다운로드 (960 Bytes)
1 |
var baseRest = require('./_baseRest'), |
---|---|
2 |
unzipWith = require('./unzipWith');
|
3 |
|
4 |
/**
|
5 |
* This method is like `_.zip` except that it accepts `iteratee` to specify
|
6 |
* how grouped values should be combined. The iteratee is invoked with the
|
7 |
* elements of each group: (...group).
|
8 |
*
|
9 |
* @static
|
10 |
* @memberOf _
|
11 |
* @since 3.8.0
|
12 |
* @category Array
|
13 |
* @param {...Array} [arrays] The arrays to process.
|
14 |
* @param {Function} [iteratee=_.identity] The function to combine
|
15 |
* grouped values.
|
16 |
* @returns {Array} Returns the new array of grouped elements.
|
17 |
* @example
|
18 |
*
|
19 |
* _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
|
20 |
* return a + b + c;
|
21 |
* });
|
22 |
* // => [111, 222]
|
23 |
*/
|
24 |
var zipWith = baseRest(function(arrays) { |
25 |
var length = arrays.length,
|
26 |
iteratee = length > 1 ? arrays[length - 1] : undefined; |
27 |
|
28 |
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; |
29 |
return unzipWith(arrays, iteratee);
|
30 |
}); |
31 |
|
32 |
module.exports = zipWith; |