UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

21 lines (18 loc) 485 B
import { unzip } from './unzip.mjs'; import { isFunction } from '../../predicate/isFunction.mjs'; function zipWith(...combine) { let iteratee = combine.pop(); if (!isFunction(iteratee)) { combine.push(iteratee); iteratee = undefined; } if (!combine?.length) { return []; } const result = unzip(combine); if (iteratee == null) { return result; } return result.map(group => iteratee(...group)); } export { zipWith };