mindee
Version:
Mindee Client Library for Node.js
34 lines (33 loc) • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AmountField = void 0;
const field_1 = require("./field");
const common_1 = require("../common");
/**
* A field containing an amount value.
*/
class AmountField extends field_1.Field {
/**
* @param {BaseFieldConstructor} constructor Constructor parameters.
*/
constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId = undefined, }) {
super({ prediction, valueKey, reconstructed, pageId });
/** The value. */
this.value = undefined;
this.value = +parseFloat(prediction[valueKey]);
if (isNaN(this.value)) {
this.value = undefined;
this.confidence = 0.0;
}
}
/**
* Default string representation.
*/
toString() {
if (this.value !== undefined) {
return (0, common_1.floatToString)(this.value);
}
return "";
}
}
exports.AmountField = AmountField;