/**
 * Assert that no NaN values are present in an array.
 * @param {Array} arr 
 * @param {string} label 
 */
function assertNoNaN(arr, label = "array") {
    if (Array.isArray(arr)) {
        for (const el of arr) {
            assertNoNaN(el, label);
        }
    } else {
        if (Number.isNaN(arr)) {
            throw new Error(`NaN detected in ${label}!`);
        }
    }
}

module.exports = { assertNoNaN };