"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const curry_1 = require("@arrows/composition/curry");
const _update_ = (updaterFn, index, arr) => {
    if (index > arr.length - 1) {
        throw new Error("The provided index is out of bound of the array.");
    }
    const newArr = [...arr];
    newArr[index] = updaterFn(newArr[index]);
    return newArr;
};
/**
 * Creates a new array with a new value at the provided index,
 * calculated by updater function that maps an old value into a new one.
 *
 * If the index is out of bound of the array throws an error.
 *
 * @param value New value
 * @param index Specific index
 * @param arr Initial array
 * @returns New array
 */
const update_ = curry_1.default(_update_);
exports.update_ = update_;
exports.default = update_;
