"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const curry_1 = require("@arrows/composition/curry");
const _fill = (startIndex, endIndex, value, arr) => {
    return [...arr].fill(value, startIndex, endIndex);
};
const _fillStart = (startIndex, value, arr) => _fill(startIndex, undefined, value, arr);
const fillStart = curry_1.default(_fillStart);
const curriedFill = curry_1.default(_fill);
/**
 * Creates a new array with section identified by start and end index
 * filled with provided value.
 * Have built-in methods for common cases.
 *
 * @param startIndex Start index (if undefined - fill from start)
 * @param endIndex End index (if undefined - fill to the end)
 * @param value Value with which selected section will be filled.
 * @param arr Initial array
 * @returns New array
 *
 * @method all Fill from the start to the end
 * @method end Fill from the specified index to the end
 * @method start Fill from the specified index to the end
 */
const fill = Object.assign(curriedFill, {
    /**
     * Fill from the start to the end.
     *
     * @param value Value with which selected section will be filled.
     * @param arr Initial array
     * @returns New array
     */
    all: curriedFill(0, undefined),
    /**
     * Fill from the start to the specified index.
     *
     * @param endIndex End index
     * @param value Value with which selected section will be filled.
     * @param arr Initial array
     * @returns New array
     */
    end: curriedFill(0),
    /**
     * Fill from the specified index to the end.
     *
     * @param startIndex Start index
     * @param value Value with which selected section will be filled.
     * @param arr Initial array
     * @returns New array
     */
    start: fillStart,
});
exports.fill = fill;
exports.default = fill;
