Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zipWith.js 960B

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