UNPKG

mindee

Version:

Mindee Client Library for Node.js

75 lines (74 loc) 2.57 kB
/* eslint-disable @typescript-eslint/naming-convention */ /** * Confidence level of a field as returned by the V2 API. */ export var FieldConfidence; (function (FieldConfidence) { FieldConfidence["Certain"] = "Certain"; FieldConfidence["High"] = "High"; FieldConfidence["Medium"] = "Medium"; FieldConfidence["Low"] = "Low"; })(FieldConfidence || (FieldConfidence = {})); // eslint-disable-next-line @typescript-eslint/no-namespace (function (FieldConfidence) { /** * Converts a FieldConfidence value to an integer. * @param confidence The FieldConfidence value to convert * @returns Integer representation (Certain=4, High=3, Medium=2, Low=1) */ function toInt(confidence) { switch (confidence) { case FieldConfidence.Certain: return 4; case FieldConfidence.High: return 3; case FieldConfidence.Medium: return 2; case FieldConfidence.Low: return 1; default: throw new Error(`Unknown FieldConfidence value: ${confidence}`); } } FieldConfidence.toInt = toInt; /** * Checks if the first FieldConfidence is greater than the second. * @param a First FieldConfidence value * @param b Second FieldConfidence value * @returns true if a > b */ function greaterThan(a, b) { return toInt(a) > toInt(b); } FieldConfidence.greaterThan = greaterThan; /** * Checks if the first FieldConfidence is greater than or equal to the second. * @param a First FieldConfidence value * @param b Second FieldConfidence value * @returns true if a >= b */ function greaterThanOrEqual(a, b) { return toInt(a) >= toInt(b); } FieldConfidence.greaterThanOrEqual = greaterThanOrEqual; /** * Checks if the first FieldConfidence is less than the second. * @param a First FieldConfidence value * @param b Second FieldConfidence value * @returns true if a < b */ function lessThan(a, b) { return toInt(a) < toInt(b); } FieldConfidence.lessThan = lessThan; /** * Checks if the first FieldConfidence is less than or equal to the second. * @param a First FieldConfidence value * @param b Second FieldConfidence value * @returns true if a <= b */ function lessThanOrEqual(a, b) { return toInt(a) <= toInt(b); } FieldConfidence.lessThanOrEqual = lessThanOrEqual; })(FieldConfidence || (FieldConfidence = {}));