function padReflect(array, left, right) {
    // @ts-ignore
    const padded = new array.constructor(array.length + left + right);
    const w = array.length - 1;

    for (let i = 0; i < array.length; ++i) {
        padded[left + i] = array[i];
    }

    for (let i = 1; i <= left; ++i) {
        padded[left - i] = array[calculateReflectOffset(i, w)];
    }

    for (let i = 1; i <= right; ++i) {
        padded[w + left + i] = array[calculateReflectOffset(w - i, w)];
    }

    return padded;
}
@template {Float32Array|Float64Array} T
Pads an array with a reflected version of itself on both ends.
@param {T} array The array to pad.
@param {number} left The amount of padding to add to the left.
@param {number} right The amount of padding to add to the right.
@returns {T} The padded array.