Fix number comparisons for position values
This commit is contained in:
@@ -40,7 +40,7 @@ class MeasurementBuilder {
|
||||
if (!this.variant) {
|
||||
throw new Error('Measurement variant is required');
|
||||
}
|
||||
if (!this.position) {
|
||||
if (Number.isNaN(this.position)) {
|
||||
throw new Error('Measurement position is required');
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ class MeasurementContainer {
|
||||
// Emit the exact event your parent expects
|
||||
this.emitter.emit(`${this._currentType}.${this._currentVariant}.${this._convertPositionNum2Str(this._currentPosition)}`, eventData);
|
||||
this.emitter.emit(`${this._currentType}.${this._currentVariant}.${this._currentPosition}`, eventData);
|
||||
//console.log(`Emitted event: ${this._currentType}.${this._currentVariant}.${this._currentPosition}`, eventData);
|
||||
// console.log(`Emitted event: ${this._currentType}.${this._currentVariant}.${this._currentPosition}`, eventData);
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class MeasurementContainer {
|
||||
|
||||
// Helper methods
|
||||
_ensureChainIsValid() {
|
||||
if (!this._currentType || !this._currentVariant || !this._currentPosition) {
|
||||
if (!this._currentType || !this._currentVariant || Number.isNaN(this._currentPosition)) {
|
||||
if (this.logger) {
|
||||
this.logger.error('Incomplete measurement chain, required: type, variant, and position');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user