"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const curry_1 = require("@arrows/composition/curry");
const _zipAllWith_ = (zippingFn, otherArr, arr) => {
    const length = Math.max(arr.length, otherArr.length);
    const newArr = [];
    for (let i = 0; i < length; i++) {
        const value = zippingFn(otherArr[i], arr[i]);
        newArr.push(value);
    }
    return newArr;
};
const zipAllWith_ = curry_1.default(_zipAllWith_);
const _zipWith_ = (zippingFn, otherArr, arr) => {
    const length = Math.min(arr.length, otherArr.length);
    const newArr = [];
    for (let i = 0; i < length; i++) {
        const value = zippingFn(otherArr[i], arr[i]);
        newArr.push(value);
    }
    return newArr;
};
const curriedZipWith_ = curry_1.default(_zipWith_);
/**
 * Zips two arrays producing new values with a zipping function,
 * that takes elements with the same indexes.
 * Zips until the length of the shorter array is reached.
 *
 * @param zippingFn Zipping function
 * @param otherArr Array that you want to zip with initial array
 * @param arr Initial array
 * @returns New, zipped array
 *
 * @method all Zips until the length of the longer array is reached
 */
const zipWith_ = Object.assign(curriedZipWith_, {
    /**
     * Zips until the length of the longer array is reached.
     *
     * @param zippingFn Zipping function
     * @param otherArr Array that you want to zip with initial array
     * @param arr Initial array
     * @returns New, zipped array
     */
    all: zipAllWith_,
});
exports.zipWith_ = zipWith_;
exports.default = zipWith_;
