- Fix missing return in childRegistrationUtils.registerChild() - Fix assertionUtils: assertNoNaN uses this.assertNoNaN - Fix logger: nameModule uses this.nameModule - Fix assetUtils: convert ESM to CommonJS - Fix childRegistrationUtils_DEPRECATED: desc -> softwareType - Add gravity export to index.js for rotatingMachine - Fix ESLint errors across 18 files (no-undef, no-case-declarations, no-mixed-spaces-and-tabs, parsing errors) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
835 B
JavaScript
29 lines
835 B
JavaScript
/**
|
|
* @file assertionUtils.js
|
|
*
|
|
* Utility functions for assertions and throwing errors in EVOLV.
|
|
*
|
|
* @description This module provides functions to assert conditions and throw errors when those conditions are not met.
|
|
* @exports ValidationUtils
|
|
*/
|
|
|
|
class Assertions {
|
|
/**
|
|
* Assert that no NaN values are present in an array.
|
|
* @param {Array} arr - The array to check for NaN values.
|
|
* @param {string} label - Array label to indicate where the error occurs.
|
|
*/
|
|
assertNoNaN(arr, label = "array") {
|
|
if (Array.isArray(arr)) {
|
|
for (const el of arr) {
|
|
this.assertNoNaN(el, label);
|
|
}
|
|
} else {
|
|
if (Number.isNaN(arr)) {
|
|
throw new Error(`NaN detected in ${label}!`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Assertions; |