import { assert } from "../../assert.js";

/**
 * @template T
 * @param {T[]|Uint32Array} array
 * @param {T} needle
 * @param {number} min_index
 * @param {number} max_index
 */
export function array_get_index_in_range(array, needle, min_index, max_index) {
    assert.lessThanOrEqual(max_index, array.length - 1, 'max_length must is too large');
    assert.isNonNegativeInteger(min_index, 'min_index');

    for (let i = min_index; i <= max_index; i++) {
        if (array[i] === needle) {
            return i;
        }
    }

    return -1;
}
