@lhncbc/ucum-lhc 7.1.2 → 7.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lhncbc/ucum-lhc",
3
- "version": "7.1.2",
3
+ "version": "7.1.3",
4
4
  "description": "Implements Unified Code for Units of Measure (UCUM) functions in a javascript library",
5
5
  "main": "source-cjs/ucumPkg.js",
6
6
  "homepage": "https://lhncbc.github.io/ucum-lhc/",
@@ -784,7 +784,7 @@ export class UnitString {
784
784
  let psIdx = pStr.indexOf(this.parensFlag_);
785
785
  let befText = null;
786
786
  if (psIdx > 0) {
787
- befText = pStr.substr(0, psIdx - 1);
787
+ befText = pStr.substring(0, psIdx);
788
788
  }
789
789
  let peIdx = pStr.lastIndexOf(this.parensFlag_);
790
790
  let aftText = null;
@@ -843,20 +843,12 @@ export class UnitString {
843
843
  `code is invalid.\n` + this.vcMsgStart_ + pStr + this.vcMsgEnd_);
844
844
  }
845
845
  // else the text before the parentheses is neither a number nor
846
- // an annotation. If suggestions were NOT requested, record an
847
- // error.
848
- else if (!this.suggestions_) {
846
+ // an annotation. Record an error.
847
+ else {
849
848
  this.retMsg_.push(`${befText} preceding the unit code ${pStr} ` +
850
849
  `is invalid. Unable to make a substitution.`);
851
850
  endProcessing = true;
852
- }
853
- // otherwise try for suggestions
854
- else {
855
- let suggestStat = this._getSuggestions(befText);
856
- endProcessing = (suggestStat !== 'succeeded');
857
-
858
- } // end if a brace was found or, if not, suggestions were not or
859
- // were requested
851
+ } // end if a brace was found
860
852
  } // end if text preceding the parentheses was not a number
861
853
  } // end if there was text before the parentheses
862
854
 
@@ -895,17 +887,11 @@ export class UnitString {
895
887
  endProcessing = true;
896
888
  }
897
889
  // else the text after the parentheses is neither a number nor
898
- // an annotation. If suggestions were NOT requested, record an
899
- // error.
900
- else if (!this.suggestions_) {
890
+ // an annotation. Record an error.
891
+ else {
901
892
  this.retMsg_.push(`Text ${aftText} following the unit code ${pStr} ` +
902
893
  `is invalid. Unable to make a substitution.`);
903
894
  endProcessing = true;
904
- }
905
- // otherwise try for suggestions
906
- else {
907
- let suggestStat = this._getSuggestions(befText);
908
- endProcessing = (suggestStat !== 'succeeded');
909
895
  } // end if text following the parentheses not an exponent
910
896
  } // end if text following the parentheses is not an annotation
911
897
  } // end if there is text following the parentheses
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.UcumLhcUtils = void 0;
7
7
  var _ucumJsonDefs = require("./ucumJsonDefs.js");
8
8
  var intUtils_ = _interopRequireWildcard(require("./ucumInternalUtils.js"));
9
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
10
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
10
  /**
12
11
  * This class provides a single point of access to the LHC UCUM utilities
13
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ucumLhcUtils.js","names":["_ucumJsonDefs","require","intUtils_","_interopRequireWildcard","_getRequireWildcardCache","WeakMap","cache","obj","__esModule","default","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Ucum","UnitTables","UnitString","UcumLhcUtils","constructor","getInstance","unitsCount","ucumJsonDefs","loadJsonDefs","uStrParser_","massDimIndex_","getMassDimensionIndex","useHTMLInMessages","use","undefined","useBraceMsgForEachString","validateUnitString","uStr","suggest","valConv","resp","getSpecifiedUnit","theUnit","retObj","csCode_","name_","guidance_","status","detectConversionType","fromUnit","toUnit","conversionType","moleExp_","equivalentExp_","dim_","getElementAt","convertUnitTo","fromUnitCode","fromVal","toUnitCode","options","molecularWeight","charge","returnObj","trim","push","_checkFromVal","parseResp","concat","convertType","msgCountBeforeConvert","length","convertFrom","err","message","isMolMassCommensurable","needMoleWeightMsg_","convertMolMass","isEqMassCommensurable","needEqWeightMsg_","needEqChargeMsg_","convertEqMass","isEqMolCommensurable","convertEqMol","isEqMolMassCommensurable","convertEqMolMass","convertToBaseUnits","inputUnitLookup","unit","msg","retMsg","isArbitrary_","unitToExp","dimVec","dimVec_","baseUnitString","dimVecIndexToBaseUnit","dimVecIndexToBaseUnit_","i","len","exp","retUnitLookup","retUnit","magnitude","e","toString","fromUnitIsSpecial","isSpecial_","responseObj","isNaN","isNumericString","checkSynonyms","theSyn","getSynonyms","uName","utab","getUnitByCode","parseString","console","log","unshift","origString","commensurablesList","fromName","categoryList","commUnits","fromDim","getProperty","getUnitsByDimension","filter","item","indexOf","category_","exports"],"sources":["../source/ucumLhcUtils.js"],"sourcesContent":["/**\n * This class provides a single point of access to the LHC UCUM utilities\n *\n * @author Lee Mericle\n *\n */\nvar Ucum = require('./config.js').Ucum;\nimport {ucumJsonDefs} from './ucumJsonDefs.js';\nvar UnitTables = require('./unitTables.js').UnitTables;\nvar UnitString = require('./unitString.js').UnitString;\n\nimport * as intUtils_ from \"./ucumInternalUtils.js\";\n\n/**\n * UCUM external utilities class\n */\nexport class UcumLhcUtils {\n\n /**\n * Constructor. This loads the json prefix and unit definitions if\n * they haven't been loaded already and creates itself as a singleton object.\n *\n */\n constructor() {\n\n if (UnitTables.getInstance().unitsCount() === 0) {\n\n // Load the prefix and unit objects\n ucumJsonDefs.loadJsonDefs();\n }\n\n // Get the UnitString parser that will be used with this instance\n // of the LHC Utilities\n this.uStrParser_ = UnitString.getInstance();\n\n // Get a copy of the mass dimension index.\n this.massDimIndex_ = UnitTables.getInstance().getMassDimensionIndex();\n } // end constructor\n\n\n /**\n * This method calls the useHTMLInMessages method on the UnitString\n * object. It should be called by web applications that use\n * these utilities.\n *\n * @param use flag indicating whether or not to use the braces message;\n * defaults to true\n */\n useHTMLInMessages(use) {\n if (use === undefined)\n use = true ;\n this.uStrParser_.useHTMLInMessages(use);\n }\n\n\n /**\n * This method calls the useBraceMsgForEachString method on the UnitString\n * object. It should be called by web applications where unit\n * strings are validated individually (as opposed to validating a whole\n * file of unit strings).\n *\n * @param use flag indicating whether or not to use the braces message;\n * defaults to true\n */\n useBraceMsgForEachString(use) {\n if (use === undefined)\n use = true ;\n this.uStrParser_.useBraceMsgForEachString(use);\n }\n\n\n /**\n * This method validates a unit string. It first checks to see if the\n * string passed in is a unit code that is found in the unit codes table.\n * If it is not found it parses the string to see if it resolves to a\n * valid unit string.\n *\n * If a valid unit cannot be found, the string is tested for some common\n * errors, such as missing brackets or a missing multiplication operator.\n * If found, the error is reported in the messages array that is returned.\n *\n * If a valid unit cannot be found and an error cannot be discerned, this\n * may return, if requested, a list of suggested units in the messages\n * array that is returned. Suggestions are based on matching the expression\n * with unit names and synonyms.\n *\n * @param uStr the string to be validated\n * @param suggest a boolean to indicate whether or not suggestions are\n * requested for a string that cannot be resolved to a valid unit;\n * true indicates suggestions are wanted; false indicates they are not,\n * and is the default if the parameter is not specified;\n * @param valConv a string indicating if this validation request was initiated\n * by a validation task ('validate') or a conversion task ('convert'),\n * used only for the demo code, and the default is 'Validator' if the\n * parameter is not specified;\n * @returns an object with five properties:\n * 'status' will be 'valid' (the uStr is a valid UCUM code), 'invalid'\n * (the uStr is not a valid UCUM code, and substitutions or\n * suggestions may or may not be returned, depending on what was\n * requested and found); or 'error' (an input or programming error\n * occurred);\n * 'ucumCode' the valid ucum code, which may differ from what was passed\n * in (e.g., if 'Gauss' is passed in, this will contain 'G') OR null if\n * the string was flagged as invalid or an error occurred;\n * 'msg' is an array of one or more messages, if the string is invalid or\n * an error occurred, indicating the problem, or an explanation of a\n * substitution such as the substitution of 'G' for 'Gauss', or\n * an empty array if no messages were generated;\n * 'unit' which is null if no unit is found, or a hash for a unit found:\n * 'code' is the unit's ucum code (G in the above example;\n * 'name' is the unit's name (Gauss in the above example); and\n * 'guidance' is the unit's guidance/description data; and\n * 'suggestions' if suggestions were requested and found, this is an array\n * of one or more hash objects. Each hash contains three elements:\n * 'msg' which is a message indicating what part of the uStr input\n * parameter the suggestions are for;\n * 'invalidUnit' which is the unit expression the suggestions are\n * for; and\n * 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * If no suggestions were requested and found, this property is not\n * returned.\n */\n validateUnitString(uStr, suggest, valConv) {\n\n if (suggest === undefined)\n suggest = false ;\n\n if (valConv === undefined)\n valConv = 'validate' ;\n\n let resp = this.getSpecifiedUnit(uStr, valConv, suggest);\n let theUnit = resp['unit'];\n let retObj = !theUnit ? {'ucumCode': null} :\n {'ucumCode': resp['origString'],\n 'unit': {'code': theUnit.csCode_,\n 'name': theUnit.name_,\n 'guidance': theUnit.guidance_ }};\n retObj.status = resp.status;\n if (resp['suggestions']) {\n retObj['suggestions'] = resp['suggestions'];\n }\n retObj['msg'] = resp['retMsg'];\n return retObj;\n\n } // end validateUnitString\n\n\n// Note that below when the value of ConversionType is mol|mass, it refers to\n// either a conversion from mol to mass or from mass to mol.\n/**\n * @typedef {\n * 'normal',\n * 'mol|mass',\n * 'eq|mass',\n * 'eq|mol',\n * 'eq|mol|mass'\n * } ConversionType\n */\n\n /**\n * Detects the type of conversion between two units.\n *\n * @param {Object} fromUnit - The unit to convert from.\n * @param {Object} toUnit - The unit to convert to.\n * @returns {ConversionType} conversionType - The type of conversion as a string.\n */\n detectConversionType(fromUnit, toUnit) {\n /** @type {ConversionType} */\n let conversionType;\n if (fromUnit.moleExp_ == toUnit.moleExp_ &&\n fromUnit.equivalentExp_ == toUnit.equivalentExp_) {\n // Since the powers of the equivalents and mole in the units are the same in both\n // units, no conversion is going to happen between mass, mol, and eq.\n // There is the possibility that someone is trying to convert 'g' to 'g2',\n // but we will handle that as the \"normal\" case (and later find it invalid).\n conversionType = 'normal';\n }\n else if (fromUnit.equivalentExp_ == toUnit.equivalentExp_) {\n // In this case, the units have the same power of equivalents, so (because\n // it is not the first case) the units have different powers of mol and mass,\n // so this must be a conversion between mol and mass.\n conversionType = 'mol|mass';\n }\n else if (fromUnit.moleExp_ == toUnit.moleExp_) {\n // In this case, the units have the same power of mol, so (because\n // it is not the first case) the units have different powers of equivalents and mass,\n // so this must be a conversion between equivalents and mass.\n conversionType = 'eq|mass';\n }\n else if (fromUnit.dim_.getElementAt(this.massDimIndex_) ==\n toUnit.dim_.getElementAt(this.massDimIndex_)) {\n // In this case, the units have the same power of mass, so (because\n // it is not the first case) the units have different powers of equivalents and mol,\n // so this must be a conversion between equivalents and moles.\n conversionType = 'eq|mol';\n }\n else {\n // In this case, the units have different powers of mass, mol, and\n // equivalents, so there is a conversion between mass, mol, and\n // equivalents.\n conversionType = 'eq|mol|mass';\n }\n\n return conversionType;\n } // end detectConversionType\n\n\n /**\n * @typedef {{\n * status: 'succeeded' | 'failed' | 'error',\n * toVal: number | null,\n * msg: string[],\n * suggestions: {\n * from: {\n * msg: string,\n * invalidUnit: string,\n * units: string[]\n * },\n * to: {\n * msg: string,\n * invalidUnit: string,\n * units: string[]\n * }\n * },\n * fromUnit: string,\n * toUnit: string\n * }} ConvertUnitResult\n */\n\n\n /**\n * This method converts one unit to another\n *\n * @param {string} fromUnitCode - the unit code/expression/string of the unit to be converted\n * @param {number | string} fromVal - the number of \"from\" units to be converted to \"to\" units\n * @param {string} toUnitCode - the unit code/expression/string of the unit that the from field is to be converted to\n * @param {{\n * suggest?: boolean,\n * molecularWeight?: number\n * charge?: number\n * }} options\n * - suggest: a boolean to indicate whether or not suggestions are requested for a string that cannot be resolved to a valid unit;\n * true indicates suggestions are wanted; false indicates they are not, and is the default if the parameter is not specified;\n * - molecularWeight: the molecular weight of the substance in question when a conversion is being requested from mass to moles and vice versa.\n * This is required when one of the units represents a value in moles. It is ignored if neither unit includes a measurement in moles.\n * - charge: the absolute value of the charge of the substance in question when a conversion is being requested from mass/moles to\n * equivalents and vice versa. It is required when one of the units represents a value in equivalents and the other in mass or moles.\n * It is ignored if neither unit includes an equivalent unit.\n * @returns {ConvertUnitResult}\n * - a hash with six elements:\n * - 'status' that will be: 'succeeded' if the conversion was successfully\n * calculated; 'failed' if the conversion could not be made, e.g., if\n * the units are not commensurable; or 'error' if an error occurred;\n * - 'toVal' the numeric value indicating the conversion amount, or null\n * if the conversion failed (e.g., if the units are not commensurable);\n * - 'msg' is an array message, if the string is invalid or an error occurred,\n * indicating the problem, or an explanation of a substitution such as\n * the substitution of 'G' for 'Gauss', or an empty array if no\n * messages were generated;\n * - 'suggestions' if suggestions were requested and found, this is a hash\n * that contains at most two elements:\n * - 'from' which, if the fromUnitCode input parameter or one or more of\n * its components could not be found, is an array one or more hash\n * objects. Each hash contains three elements:\n * - 'msg' which is a message indicating what unit expression the\n * suggestions are for;\n * - 'invalidUnit' which is the unit expression the suggestions\n * are for; and\n * - 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * If no suggestions were found for the fromUnitCode this element\n * will not be included.\n * - 'to' which, if the \"to\" unit expression or one or more of its\n * components could not be found, is an array one or more hash objects. Each hash\n * contains three elements:\n * - 'msg' which is a message indicating what toUnitCode input\n * parameter the suggestions are for;\n * - 'invalidUnit' which is the unit expression the suggestions\n * are for; and\n * - 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * If no suggestions were found for the toUnitCode this element\n * will not be included.\n * No 'suggestions' element will be included in the returned hash\n * object if none were found, whether or not they were requested.\n * - 'fromUnit' the unit object for the fromUnitCode passed in; returned\n * in case it's needed for additional data from the object; and\n * - 'toUnit' the unit object for the toUnitCode passed in; returned\n * in case it's needed for additional data from the object.\n */\n convertUnitTo(fromUnitCode, fromVal, toUnitCode, options = {}) {\n let {suggest = false, molecularWeight = null, charge = null} = options;\n\n /** @type {ConvertUnitResult} */\n let returnObj = {\n 'status': 'failed',\n 'toVal': null,\n 'msg': []\n };\n\n if (fromUnitCode) {\n fromUnitCode = fromUnitCode.trim();\n }\n if (!fromUnitCode || fromUnitCode == '') {\n returnObj['status'] = 'error';\n returnObj['msg'].push('No \"from\" unit expression specified.');\n }\n this._checkFromVal(fromVal, returnObj);\n if (toUnitCode) {\n toUnitCode = toUnitCode.trim();\n }\n if (!toUnitCode || toUnitCode == '') {\n returnObj['status'] = 'error';\n returnObj['msg'].push('No \"to\" unit expression specified.');\n }\n if (returnObj['status'] !== 'error') {\n let fromUnit = null;\n\n let parseResp = this.getSpecifiedUnit(fromUnitCode, 'convert', suggest);\n fromUnit = parseResp['unit'];\n if (parseResp['retMsg'])\n returnObj['msg'] = returnObj['msg'].concat(parseResp['retMsg']);\n if (parseResp['suggestions']) {\n returnObj['suggestions'] = {};\n returnObj['suggestions']['from'] = parseResp['suggestions'];\n }\n if (!fromUnit) {\n returnObj['msg'].push(`Unable to find a unit for ${fromUnitCode}, ` +\n `so no conversion could be performed.`);\n }\n\n let toUnit = null;\n parseResp = this.getSpecifiedUnit(toUnitCode, 'convert', suggest);\n toUnit = parseResp['unit'];\n if (parseResp['retMsg'])\n returnObj['msg'] = returnObj['msg'].concat(parseResp['retMsg']);\n if (parseResp['suggestions']) {\n if (!returnObj['suggestions'])\n returnObj['suggestions'] = {};\n returnObj['suggestions']['to'] = parseResp['suggestions'];\n }\n if (!toUnit) {\n returnObj['msg'].push(`Unable to find a unit for ${toUnitCode}, ` +\n `so no conversion could be performed.`);\n }\n\n if (fromUnit && toUnit) {\n const convertType = this.detectConversionType(fromUnit, toUnit);\n const msgCountBeforeConvert = returnObj['msg'].length;\n switch (convertType) {\n case 'normal':\n try {\n returnObj['toVal'] = toUnit.convertFrom(fromVal, fromUnit);\n } catch (err) {\n returnObj['msg'].push(err.message);\n }\n break;\n case 'mol|mass':\n if (!fromUnit.isMolMassCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!molecularWeight) {\n returnObj['msg'].push(Ucum.needMoleWeightMsg_);\n break;\n }\n returnObj['toVal'] = fromUnit.convertMolMass(fromVal, toUnit, molecularWeight);\n break;\n case 'eq|mass':\n if (!fromUnit.isEqMassCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!molecularWeight) {\n returnObj['msg'].push(Ucum.needEqWeightMsg_);\n }\n if (!charge) {\n returnObj['msg'].push(Ucum.needEqChargeMsg_);\n }\n if (!returnObj['msg'].length) {\n returnObj['toVal'] = fromUnit.convertEqMass(fromVal, toUnit, molecularWeight, charge);\n }\n break;\n case 'eq|mol':\n if (!fromUnit.isEqMolCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!charge) {\n returnObj['msg'].push(Ucum.needEqChargeMsg_);\n break;\n }\n returnObj['toVal'] = fromUnit.convertEqMol(fromVal, toUnit, charge);\n break;\n case 'eq|mol|mass':\n if (!fromUnit.isEqMolMassCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!molecularWeight) {\n returnObj['msg'].push(Ucum.needEqWeightMsg_);\n }\n if (!charge) {\n returnObj['msg'].push(Ucum.needEqChargeMsg_);\n }\n if (!returnObj['msg'].length) {\n returnObj['toVal'] = fromUnit.convertEqMolMass(fromVal, toUnit, molecularWeight, charge);\n }\n break;\n default:\n returnObj['msg'].push(\"Unknown conversion type. No conversion was attempted.\");\n }\n if (returnObj['msg'].length > msgCountBeforeConvert) {\n // If one or more failure messages are pushed into returnObj['msg']\n // in the switch statement, mark the status as 'failed'.\n returnObj['status'] = 'failed';\n } else {\n // Set the return object to show success.\n returnObj['status'] = 'succeeded';\n returnObj['fromUnit'] = fromUnit;\n returnObj['toUnit'] = toUnit;\n }\n } // end if we have the from and to units\n }\n\n return returnObj;\n\n } // end convertUnitTo\n\n\n /**\n * Converts the given unit string into its base units, their exponents, and\n * a magnitude, and returns that data.\n * @param fromUnit the unit string to be converted to base units information\n * @param fromVal the number of \"from\" units to be converted\n * @returns an object with the properties:\n * 'status' indicates whether the result succeeded. The value will be one of:\n * 'succeeded': the conversion was successfully calculated (which can be\n * true even if it was already in base units);\n * 'invalid': fromUnit is not a valid UCUM code;\n * 'failed': the conversion could not be made (e.g., if it is an \"arbitrary\" unit);\n * 'error': if an error occurred (an input or programming error)\n * 'msg': an array of messages (possibly empty) if the string is invalid or\n * an error occurred, indicating the problem, or a suggestion of a\n * substitution such as the substitution of 'G' for 'Gauss', or\n * an empty array if no messages were generated. There can also be a\n * message that is just informational or warning.\n * 'magnitude': the new value when fromVal units of fromUnits is expressed in the base units.\n * 'fromUnitIsSpecial': whether the input unit fromUnit is a \"special unit\"\n * as defined in UCUM. This means there is some function applied to convert\n * between fromUnit and the base units, so the returned magnitude is likely not\n * useful as a scale factor for other conversions (i.e., it only has validity\n * and usefulness for the input values that produced it).\n * 'unitToExp': a map of base units in fromUnit to their exponent\n */\n convertToBaseUnits(fromUnit, fromVal) {\n let retObj = {};\n this._checkFromVal(fromVal, retObj);\n if (!retObj.status) { // could be set to 'error' by _checkFromVal\n let inputUnitLookup = this.getSpecifiedUnit(fromUnit, 'validate');\n retObj = {status: inputUnitLookup.status == 'valid' ? 'succeeded' : inputUnitLookup.status};\n let unit = inputUnitLookup.unit;\n retObj.msg = inputUnitLookup.retMsg || [];\n if (!unit) {\n if (inputUnitLookup.retMsg?.length == 0)\n retObj.msg.push('Could not find unit information for '+fromUnit);\n }\n else if (unit.isArbitrary_) {\n retObj.msg.push('Arbitrary units cannot be converted to base units or other units.');\n retObj.status = 'failed';\n }\n else if (retObj.status == 'succeeded') {\n let unitToExp = {};\n let dimVec = unit.dim_?.dimVec_\n let baseUnitString = '1';\n if (dimVec) {\n let dimVecIndexToBaseUnit = UnitTables.getInstance().dimVecIndexToBaseUnit_;\n for (let i=0, len=dimVec.length; i<len; ++i) {\n let exp = dimVec[i];\n if (exp) {\n unitToExp[dimVecIndexToBaseUnit[i]] = exp;\n baseUnitString += '.' + dimVecIndexToBaseUnit[i] + exp;\n }\n }\n }\n\n // The unit might have a conversion function, which has to be applied; we\n // cannot just assume unit_.magnitude_ is the magnitude in base units.\n let retUnitLookup = this.getSpecifiedUnit(baseUnitString, 'validate');\n // There should not be any error in retUnitLookup, unless there is a bug.\n let retUnit = retUnitLookup.unit;\n if (retUnitLookup.status !== 'valid') {\n retObj.msg.push('Unable construct base unit string; tried '+baseUnitString);\n retObj.status = 'error';\n }\n else {\n try {\n retObj.magnitude = retUnit.convertFrom(fromVal, unit);\n }\n catch (e) {\n retObj.msg.push(e.toString());\n retObj.status = 'error';\n }\n if (retObj.status == 'succeeded') {\n retObj.unitToExp = unitToExp;\n retObj.fromUnitIsSpecial = unit.isSpecial_;\n }\n }\n }\n }\n return retObj;\n }\n\n\n /**\n * Checks the given value as to whether it is suitable as a \"from\" value in a\n * unit conversion. If it is not, the responseObj will have its status set\n * to 'error' and a message added.\n * @param fromVal The value to check\n * @param responseObj the object that will be updated if the value is not\n * usable.\n */\n _checkFromVal(fromVal, responseObj) {\n if (fromVal === null || isNaN(fromVal) || (typeof fromVal !== 'number' &&\n !intUtils_.isNumericString(fromVal))) {\n responseObj.status = 'error';\n if (!responseObj.msg)\n responseObj.msg = [];\n responseObj.msg.push('No \"from\" value, or an invalid \"from\" value, ' +\n 'was specified.');\n }\n }\n\n\n /**\n * This method accepts a term and looks for units that include it as\n * a synonym - or that include the term in its name.\n *\n * @param theSyn the term to search for\n * @returns a hash with up to three elements:\n * 'status' contains the status of the request, which can be 'error',\n * 'failed' or succeeded';\n * 'msg' which contains a message for an error or if no units were found; and\n * 'units' which is an array that contains one hash for each unit found:\n * 'code' is the unit's csCode_\n * 'name' is the unit's name_\n * 'guidance' is the unit's guidance_\n *\n */\n checkSynonyms(theSyn) {\n let retObj = {} ;\n if (theSyn === undefined || theSyn === null) {\n retObj['status'] = 'error';\n retObj['msg'] = 'No term specified for synonym search.'\n }\n else {\n retObj = intUtils_.getSynonyms(theSyn);\n } // end if a search synonym was supplied\n\n return retObj ;\n\n } // end checkSynonyms\n\n\n /**\n * This method parses a unit string to get (or try to get) the unit\n * represented by the string. It returns an error message if no string was specified\n * or if any errors were encountered trying to get the unit.\n *\n * @param uName the expression/string representing the unit\n * @param valConv indicates what type of request this is for - a request to\n * validate (pass in 'validate') or a request to convert (pass in 'convert')\n * @param suggest a boolean to indicate whether or not suggestions are\n * requested for a string that cannot be resolved to a valid unit;\n * true indicates suggestions are wanted; false indicates they are not,\n * and is the default if the parameter is not specified;\n * @returns a hash containing:\n * 'status' will be 'valid' (uName is a valid UCUM code), 'invalid'\n * (the uStr is not a valid UCUM code, and substitutions or\n * suggestions may or may not be returned, depending on what was\n * requested and found); or 'error' (an input or programming error\n * occurred);\n * 'unit' the unit object (or null if there were problems creating the\n * unit);\n * 'origString' the possibly updated unit string passed in;\n * 'retMsg' an array of user messages (informational, error or warning) if\n * any were generated (IF any were generated, otherwise will be an\n * empty array); and\n * 'suggestions' is an array of 1 or more hash objects. Each hash\n * contains three elements:\n * 'msg' which is a message indicating what unit expression the\n * suggestions are for;\n * 'invalidUnit' which is the unit expression the suggestions are\n * for; and\n * 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * The return hash will not contain a suggestions array if a valid unit\n * was found or if suggestions were not requested and found.\n */\n getSpecifiedUnit(uName, valConv, suggest) {\n\n if (suggest === undefined)\n suggest = false ;\n\n let retObj = {};\n retObj['retMsg'] = [];\n\n if (!uName) {\n retObj['retMsg'].push('No unit string specified.');\n }\n else {\n let utab = UnitTables.getInstance();\n uName = uName.trim();\n\n // go ahead and just try using the name as the code. This may or may not\n // work, but if it does, it cuts out a lot of parsing.\n let theUnit = utab.getUnitByCode(uName);\n\n // If we found it, set the returned unit string to what was passed in;\n // otherwise try parsing as a unit string\n if (theUnit) {\n retObj['unit'] = theUnit ;\n retObj['origString'] = uName;\n }\n else {\n try {\n let resp = this.uStrParser_.parseString(uName, valConv, suggest);\n retObj['unit'] = resp[0];\n retObj['origString'] = resp[1];\n if (resp[2])\n retObj['retMsg'] = resp[2];\n retObj['suggestions'] = resp[3];\n }\n catch (err) {\n console.log(`Unit requested for unit string ${uName}.` +\n 'request unsuccessful; error thrown = ' + err.message);\n retObj['retMsg'].unshift(`${uName} is not a valid unit. ` +\n `${err.message}`);\n }\n } // end if the unit was not found as a unit name\n } // end if a unit expression was specified\n\n // Set the status field\n if (!retObj.unit) {\n // No unit was found; check whether origString has a value\n retObj.status = !retObj.origString ? 'error' : 'invalid';\n }\n else {\n // Check whether substitutions were made to the unit string in order to\n // find the unit\n retObj.status = retObj.origString === uName ? 'valid': 'invalid';\n }\n\n return retObj;\n\n } // end getSpecifiedUnit\n\n\n /**\n * This method retrieves a list of units commensurable, i.e., that can be\n * converted from and to, a specified unit. Returns an error if the \"from\"\n * unit cannot be found. If necessary, you can filter the list of units by\n * specifying a list of unit categories that should be in the resulting list.\n *\n * @param {string} fromName - the name/unit string of the \"from\" unit\n * @param {string[] | null} [categoryList] - the list of unit categories;\n * this parameter is optional, defaults to null if not specified;\n * possible list values: 'Clinical', 'Nonclinical', 'Obsolete', 'Constant'\n * @returns an array containing two elements;\n * first element is the list of commensurable units if any were found;\n * second element is an error message if the \"from\" unit is not found\n */\n commensurablesList(fromName, categoryList = null) {\n\n let retMsg = [];\n let commUnits = null ;\n let parseResp = this.getSpecifiedUnit(fromName, 'validate', false);\n let fromUnit = parseResp['unit'];\n if (parseResp['retMsg'].length > 0)\n retMsg = parseResp['retMsg'] ;\n if (!fromUnit) {\n retMsg.push(`Could not find unit ${fromName}.`);\n }\n else {\n let dimVec = null ;\n let fromDim = fromUnit.getProperty('dim_');\n if (!fromDim) {\n retMsg.push('No commensurable units were found for ' + fromName) ;\n }\n else {\n try {\n dimVec = fromDim.getProperty('dimVec_');\n }\n catch (err) {\n retMsg.push(err.message);\n if (err.message ===\n \"Dimension does not have requested property(dimVec_)\")\n dimVec = null;\n }\n if (dimVec) {\n let utab = UnitTables.getInstance();\n commUnits = utab.getUnitsByDimension(dimVec);\n if (categoryList) {\n commUnits = commUnits.filter((item) => {\n return categoryList.indexOf(item.category_) !== -1;\n });\n }\n }\n } // end if the from unit has a dimension vector\n } // end if we found a \"from\" unit\n return [commUnits , retMsg];\n } // end commensurablesList\n\n} // end UcumLhcUtils class\n\n\n/**\n * This function exists ONLY until the original UcumLhcUtils constructor\n * is called for the first time. It's defined here in case getInstance\n * is called before the constructor. This calls the constructor.\n *\n * The constructor redefines the getInstance function to return the\n * singleton UcumLhcUtils object. This is based on the UnitTables singleton\n * implementation; see more detail in the UnitTables constructor description.\n *\n * NO LONGER TRUE - not implemented as a singleton. This method retained to\n * avoid problems with calls to it that exist throughout the code.\n *\n * @return the (formerly singleton) UcumLhcUtils object.\n */\nUcumLhcUtils.getInstance = function(){\n return new UcumLhcUtils();\n} ;\n"],"mappings":";;;;;;AAOA,IAAAA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C,iBAAiB,CAAC,CAACwB,UAAU;AAItD;AACA;AACA;AACO,MAAMC,YAAY,CAAC;EAExB;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EAAG;IAEZ,IAAIH,UAAU,CAACI,WAAW,CAAC,CAAC,CAACC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE;MAE/C;MACAC,0BAAY,CAACC,YAAY,CAAC,CAAC;IAC7B;;IAEA;IACA;IACA,IAAI,CAACC,WAAW,GAAGP,UAAU,CAACG,WAAW,CAAC,CAAC;;IAE3C;IACA,IAAI,CAACK,aAAa,GAAIT,UAAU,CAACI,WAAW,CAAC,CAAC,CAACM,qBAAqB,CAAC,CAAC;EACxE,CAAC,CAAC;;EAGF;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,iBAAiBA,CAACC,GAAG,EAAE;IACrB,IAAIA,GAAG,KAAKC,SAAS,EACnBD,GAAG,GAAG,IAAI;IACZ,IAAI,CAACJ,WAAW,CAACG,iBAAiB,CAACC,GAAG,CAAC;EACzC;;EAGA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,wBAAwBA,CAACF,GAAG,EAAE;IAC5B,IAAIA,GAAG,KAAKC,SAAS,EACnBD,GAAG,GAAG,IAAI;IACZ,IAAI,CAACJ,WAAW,CAACM,wBAAwB,CAACF,GAAG,CAAC;EAChD;;EAGA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,kBAAkBA,CAACC,IAAI,EAAEC,OAAO,EAAEC,OAAO,EAAE;IAEzC,IAAID,OAAO,KAAKJ,SAAS,EACvBI,OAAO,GAAG,KAAK;IAEjB,IAAIC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AQ,EAAE;MAC7C;MACA;MACA;MACAD,cAAc,GAAG,SAAS;IAC5B,CAAC,MACI,IAAIF,QAAQ,CAACK,IAAI,CAACC,YAAY,CAAC,IAAI,CAACzB,aAAa,CAAC,IACjDoB,MAAM,CAACI,IAAI,CAACC,YAAY,CAAC,IAAI,CAACzB,aAAa,CAAC,EAAE;MAClD;MACA;MACA;MACAqB,cAAc,GAAG,QAAQ;IAC3B,CAAC,MACI;MACH;MACA;MACA;MACAA,cAAc,GAAG,aAAa;IAChC;IAEA,OAAOA,cAAc;EACvB,CAAC,CAAC;;EAGF;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,aAAaA,CAACC,YAAY,EAAEC,OAAO,EAAEC,UAAU,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;IAC7D,IAAI;MAACtB,OAAO,GAAG,KAAK;MAAEuB,eAAe,GAAG,IAAI;MAAEC,MAAM,GAAG;IAAI,CAAC,GAAGF,OAAO;;IAEtE;IACA,IAAIG,SAAS,GAAG;MACd,QAAQ,EAAE,QAAQ;MAClB,OAAO,EAAE,IAAI;MACb,KAAK,EAAE;IACT,CAAC;IAED,IAAIN,YAAY,EAAE;MAChBA,YAAY,GAAGA,YAAY,CAACO,IAAI,CAAC,CAAC;IACpC;IACA,IAAI,CAACP,YAAY,IAAIA,YAAY,IAAI,EAAE,EAAE;MACvCM,SAAS,CAAC,QAAQ,C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K;cACrC,OAAON,YAAY,CAACO,OAAO,CAACD,IAAI,CAACE,SAAS,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC,CAAC;UACJ;QACF;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAACP,SAAS,EAAGnC,MAAM,CAAC;EAC7B,CAAC,CAAC;AAEJ,CAAC,CAAC;;AAGF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbA2C,OAAA,CAAA9G,YAAA,GAAAA,YAAA;AAcAA,YAAY,CAACE,WAAW,GAAG,YAAU;EACnC,OAAO,IAAIF,YAAY,CAAC,CAAC;AAC3B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ucumLhcUtils.js","names":["_ucumJsonDefs","require","intUtils_","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Ucum","UnitTables","UnitString","UcumLhcUtils","constructor","getInstance","unitsCount","ucumJsonDefs","loadJsonDefs","uStrParser_","massDimIndex_","getMassDimensionIndex","useHTMLInMessages","use","undefined","useBraceMsgForEachString","validateUnitString","uStr","suggest","valConv","resp","getSpecifiedUnit","theUnit","retObj","csCode_","name_","guidance_","status","detectConversionType","fromUnit","toUnit","conversionType","moleExp_","equivalentExp_","dim_","getElementAt","convertUnitTo","fromUnitCode","fromVal","toUnitCode","options","molecularWeight","charge","returnObj","trim","push","_checkFromVal","parseResp","concat","convertType","msgCountBeforeConvert","length","convertFrom","err","message","isMolMassCommensurable","needMoleWeightMsg_","convertMolMass","isEqMassCommensurable","needEqWeightMsg_","needEqChargeMsg_","convertEqMass","isEqMolCommensurable","convertEqMol","isEqMolMassCommensurable","convertEqMolMass","convertToBaseUnits","inputUnitLookup","unit","msg","retMsg","isArbitrary_","unitToExp","dimVec","dimVec_","baseUnitString","dimVecIndexToBaseUnit","dimVecIndexToBaseUnit_","len","exp","retUnitLookup","retUnit","magnitude","toString","fromUnitIsSpecial","isSpecial_","responseObj","isNaN","isNumericString","checkSynonyms","theSyn","getSynonyms","uName","utab","getUnitByCode","parseString","console","log","unshift","origString","commensurablesList","fromName","categoryList","commUnits","fromDim","getProperty","getUnitsByDimension","filter","item","indexOf","category_","exports"],"sources":["../source/ucumLhcUtils.js"],"sourcesContent":["/**\n * This class provides a single point of access to the LHC UCUM utilities\n *\n * @author Lee Mericle\n *\n */\nvar Ucum = require('./config.js').Ucum;\nimport {ucumJsonDefs} from './ucumJsonDefs.js';\nvar UnitTables = require('./unitTables.js').UnitTables;\nvar UnitString = require('./unitString.js').UnitString;\n\nimport * as intUtils_ from \"./ucumInternalUtils.js\";\n\n/**\n * UCUM external utilities class\n */\nexport class UcumLhcUtils {\n\n /**\n * Constructor. This loads the json prefix and unit definitions if\n * they haven't been loaded already and creates itself as a singleton object.\n *\n */\n constructor() {\n\n if (UnitTables.getInstance().unitsCount() === 0) {\n\n // Load the prefix and unit objects\n ucumJsonDefs.loadJsonDefs();\n }\n\n // Get the UnitString parser that will be used with this instance\n // of the LHC Utilities\n this.uStrParser_ = UnitString.getInstance();\n\n // Get a copy of the mass dimension index.\n this.massDimIndex_ = UnitTables.getInstance().getMassDimensionIndex();\n } // end constructor\n\n\n /**\n * This method calls the useHTMLInMessages method on the UnitString\n * object. It should be called by web applications that use\n * these utilities.\n *\n * @param use flag indicating whether or not to use the braces message;\n * defaults to true\n */\n useHTMLInMessages(use) {\n if (use === undefined)\n use = true ;\n this.uStrParser_.useHTMLInMessages(use);\n }\n\n\n /**\n * This method calls the useBraceMsgForEachString method on the UnitString\n * object. It should be called by web applications where unit\n * strings are validated individually (as opposed to validating a whole\n * file of unit strings).\n *\n * @param use flag indicating whether or not to use the braces message;\n * defaults to true\n */\n useBraceMsgForEachString(use) {\n if (use === undefined)\n use = true ;\n this.uStrParser_.useBraceMsgForEachString(use);\n }\n\n\n /**\n * This method validates a unit string. It first checks to see if the\n * string passed in is a unit code that is found in the unit codes table.\n * If it is not found it parses the string to see if it resolves to a\n * valid unit string.\n *\n * If a valid unit cannot be found, the string is tested for some common\n * errors, such as missing brackets or a missing multiplication operator.\n * If found, the error is reported in the messages array that is returned.\n *\n * If a valid unit cannot be found and an error cannot be discerned, this\n * may return, if requested, a list of suggested units in the messages\n * array that is returned. Suggestions are based on matching the expression\n * with unit names and synonyms.\n *\n * @param uStr the string to be validated\n * @param suggest a boolean to indicate whether or not suggestions are\n * requested for a string that cannot be resolved to a valid unit;\n * true indicates suggestions are wanted; false indicates they are not,\n * and is the default if the parameter is not specified;\n * @param valConv a string indicating if this validation request was initiated\n * by a validation task ('validate') or a conversion task ('convert'),\n * used only for the demo code, and the default is 'Validator' if the\n * parameter is not specified;\n * @returns an object with five properties:\n * 'status' will be 'valid' (the uStr is a valid UCUM code), 'invalid'\n * (the uStr is not a valid UCUM code, and substitutions or\n * suggestions may or may not be returned, depending on what was\n * requested and found); or 'error' (an input or programming error\n * occurred);\n * 'ucumCode' the valid ucum code, which may differ from what was passed\n * in (e.g., if 'Gauss' is passed in, this will contain 'G') OR null if\n * the string was flagged as invalid or an error occurred;\n * 'msg' is an array of one or more messages, if the string is invalid or\n * an error occurred, indicating the problem, or an explanation of a\n * substitution such as the substitution of 'G' for 'Gauss', or\n * an empty array if no messages were generated;\n * 'unit' which is null if no unit is found, or a hash for a unit found:\n * 'code' is the unit's ucum code (G in the above example;\n * 'name' is the unit's name (Gauss in the above example); and\n * 'guidance' is the unit's guidance/description data; and\n * 'suggestions' if suggestions were requested and found, this is an array\n * of one or more hash objects. Each hash contains three elements:\n * 'msg' which is a message indicating what part of the uStr input\n * parameter the suggestions are for;\n * 'invalidUnit' which is the unit expression the suggestions are\n * for; and\n * 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * If no suggestions were requested and found, this property is not\n * returned.\n */\n validateUnitString(uStr, suggest, valConv) {\n\n if (suggest === undefined)\n suggest = false ;\n\n if (valConv === undefined)\n valConv = 'validate' ;\n\n let resp = this.getSpecifiedUnit(uStr, valConv, suggest);\n let theUnit = resp['unit'];\n let retObj = !theUnit ? {'ucumCode': null} :\n {'ucumCode': resp['origString'],\n 'unit': {'code': theUnit.csCode_,\n 'name': theUnit.name_,\n 'guidance': theUnit.guidance_ }};\n retObj.status = resp.status;\n if (resp['suggestions']) {\n retObj['suggestions'] = resp['suggestions'];\n }\n retObj['msg'] = resp['retMsg'];\n return retObj;\n\n } // end validateUnitString\n\n\n// Note that below when the value of ConversionType is mol|mass, it refers to\n// either a conversion from mol to mass or from mass to mol.\n/**\n * @typedef {\n * 'normal',\n * 'mol|mass',\n * 'eq|mass',\n * 'eq|mol',\n * 'eq|mol|mass'\n * } ConversionType\n */\n\n /**\n * Detects the type of conversion between two units.\n *\n * @param {Object} fromUnit - The unit to convert from.\n * @param {Object} toUnit - The unit to convert to.\n * @returns {ConversionType} conversionType - The type of conversion as a string.\n */\n detectConversionType(fromUnit, toUnit) {\n /** @type {ConversionType} */\n let conversionType;\n if (fromUnit.moleExp_ == toUnit.moleExp_ &&\n fromUnit.equivalentExp_ == toUnit.equivalentExp_) {\n // Since the powers of the equivalents and mole in the units are the same in both\n // units, no conversion is going to happen between mass, mol, and eq.\n // There is the possibility that someone is trying to convert 'g' to 'g2',\n // but we will handle that as the \"normal\" case (and later find it invalid).\n conversionType = 'normal';\n }\n else if (fromUnit.equivalentExp_ == toUnit.equivalentExp_) {\n // In this case, the units have the same power of equivalents, so (because\n // it is not the first case) the units have different powers of mol and mass,\n // so this must be a conversion between mol and mass.\n conversionType = 'mol|mass';\n }\n else if (fromUnit.moleExp_ == toUnit.moleExp_) {\n // In this case, the units have the same power of mol, so (because\n // it is not the first case) the units have different powers of equivalents and mass,\n // so this must be a conversion between equivalents and mass.\n conversionType = 'eq|mass';\n }\n else if (fromUnit.dim_.getElementAt(this.massDimIndex_) ==\n toUnit.dim_.getElementAt(this.massDimIndex_)) {\n // In this case, the units have the same power of mass, so (because\n // it is not the first case) the units have different powers of equivalents and mol,\n // so this must be a conversion between equivalents and moles.\n conversionType = 'eq|mol';\n }\n else {\n // In this case, the units have different powers of mass, mol, and\n // equivalents, so there is a conversion between mass, mol, and\n // equivalents.\n conversionType = 'eq|mol|mass';\n }\n\n return conversionType;\n } // end detectConversionType\n\n\n /**\n * @typedef {{\n * status: 'succeeded' | 'failed' | 'error',\n * toVal: number | null,\n * msg: string[],\n * suggestions: {\n * from: {\n * msg: string,\n * invalidUnit: string,\n * units: string[]\n * },\n * to: {\n * msg: string,\n * invalidUnit: string,\n * units: string[]\n * }\n * },\n * fromUnit: string,\n * toUnit: string\n * }} ConvertUnitResult\n */\n\n\n /**\n * This method converts one unit to another\n *\n * @param {string} fromUnitCode - the unit code/expression/string of the unit to be converted\n * @param {number | string} fromVal - the number of \"from\" units to be converted to \"to\" units\n * @param {string} toUnitCode - the unit code/expression/string of the unit that the from field is to be converted to\n * @param {{\n * suggest?: boolean,\n * molecularWeight?: number\n * charge?: number\n * }} options\n * - suggest: a boolean to indicate whether or not suggestions are requested for a string that cannot be resolved to a valid unit;\n * true indicates suggestions are wanted; false indicates they are not, and is the default if the parameter is not specified;\n * - molecularWeight: the molecular weight of the substance in question when a conversion is being requested from mass to moles and vice versa.\n * This is required when one of the units represents a value in moles. It is ignored if neither unit includes a measurement in moles.\n * - charge: the absolute value of the charge of the substance in question when a conversion is being requested from mass/moles to\n * equivalents and vice versa. It is required when one of the units represents a value in equivalents and the other in mass or moles.\n * It is ignored if neither unit includes an equivalent unit.\n * @returns {ConvertUnitResult}\n * - a hash with six elements:\n * - 'status' that will be: 'succeeded' if the conversion was successfully\n * calculated; 'failed' if the conversion could not be made, e.g., if\n * the units are not commensurable; or 'error' if an error occurred;\n * - 'toVal' the numeric value indicating the conversion amount, or null\n * if the conversion failed (e.g., if the units are not commensurable);\n * - 'msg' is an array message, if the string is invalid or an error occurred,\n * indicating the problem, or an explanation of a substitution such as\n * the substitution of 'G' for 'Gauss', or an empty array if no\n * messages were generated;\n * - 'suggestions' if suggestions were requested and found, this is a hash\n * that contains at most two elements:\n * - 'from' which, if the fromUnitCode input parameter or one or more of\n * its components could not be found, is an array one or more hash\n * objects. Each hash contains three elements:\n * - 'msg' which is a message indicating what unit expression the\n * suggestions are for;\n * - 'invalidUnit' which is the unit expression the suggestions\n * are for; and\n * - 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * If no suggestions were found for the fromUnitCode this element\n * will not be included.\n * - 'to' which, if the \"to\" unit expression or one or more of its\n * components could not be found, is an array one or more hash objects. Each hash\n * contains three elements:\n * - 'msg' which is a message indicating what toUnitCode input\n * parameter the suggestions are for;\n * - 'invalidUnit' which is the unit expression the suggestions\n * are for; and\n * - 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * If no suggestions were found for the toUnitCode this element\n * will not be included.\n * No 'suggestions' element will be included in the returned hash\n * object if none were found, whether or not they were requested.\n * - 'fromUnit' the unit object for the fromUnitCode passed in; returned\n * in case it's needed for additional data from the object; and\n * - 'toUnit' the unit object for the toUnitCode passed in; returned\n * in case it's needed for additional data from the object.\n */\n convertUnitTo(fromUnitCode, fromVal, toUnitCode, options = {}) {\n let {suggest = false, molecularWeight = null, charge = null} = options;\n\n /** @type {ConvertUnitResult} */\n let returnObj = {\n 'status': 'failed',\n 'toVal': null,\n 'msg': []\n };\n\n if (fromUnitCode) {\n fromUnitCode = fromUnitCode.trim();\n }\n if (!fromUnitCode || fromUnitCode == '') {\n returnObj['status'] = 'error';\n returnObj['msg'].push('No \"from\" unit expression specified.');\n }\n this._checkFromVal(fromVal, returnObj);\n if (toUnitCode) {\n toUnitCode = toUnitCode.trim();\n }\n if (!toUnitCode || toUnitCode == '') {\n returnObj['status'] = 'error';\n returnObj['msg'].push('No \"to\" unit expression specified.');\n }\n if (returnObj['status'] !== 'error') {\n let fromUnit = null;\n\n let parseResp = this.getSpecifiedUnit(fromUnitCode, 'convert', suggest);\n fromUnit = parseResp['unit'];\n if (parseResp['retMsg'])\n returnObj['msg'] = returnObj['msg'].concat(parseResp['retMsg']);\n if (parseResp['suggestions']) {\n returnObj['suggestions'] = {};\n returnObj['suggestions']['from'] = parseResp['suggestions'];\n }\n if (!fromUnit) {\n returnObj['msg'].push(`Unable to find a unit for ${fromUnitCode}, ` +\n `so no conversion could be performed.`);\n }\n\n let toUnit = null;\n parseResp = this.getSpecifiedUnit(toUnitCode, 'convert', suggest);\n toUnit = parseResp['unit'];\n if (parseResp['retMsg'])\n returnObj['msg'] = returnObj['msg'].concat(parseResp['retMsg']);\n if (parseResp['suggestions']) {\n if (!returnObj['suggestions'])\n returnObj['suggestions'] = {};\n returnObj['suggestions']['to'] = parseResp['suggestions'];\n }\n if (!toUnit) {\n returnObj['msg'].push(`Unable to find a unit for ${toUnitCode}, ` +\n `so no conversion could be performed.`);\n }\n\n if (fromUnit && toUnit) {\n const convertType = this.detectConversionType(fromUnit, toUnit);\n const msgCountBeforeConvert = returnObj['msg'].length;\n switch (convertType) {\n case 'normal':\n try {\n returnObj['toVal'] = toUnit.convertFrom(fromVal, fromUnit);\n } catch (err) {\n returnObj['msg'].push(err.message);\n }\n break;\n case 'mol|mass':\n if (!fromUnit.isMolMassCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!molecularWeight) {\n returnObj['msg'].push(Ucum.needMoleWeightMsg_);\n break;\n }\n returnObj['toVal'] = fromUnit.convertMolMass(fromVal, toUnit, molecularWeight);\n break;\n case 'eq|mass':\n if (!fromUnit.isEqMassCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!molecularWeight) {\n returnObj['msg'].push(Ucum.needEqWeightMsg_);\n }\n if (!charge) {\n returnObj['msg'].push(Ucum.needEqChargeMsg_);\n }\n if (!returnObj['msg'].length) {\n returnObj['toVal'] = fromUnit.convertEqMass(fromVal, toUnit, molecularWeight, charge);\n }\n break;\n case 'eq|mol':\n if (!fromUnit.isEqMolCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!charge) {\n returnObj['msg'].push(Ucum.needEqChargeMsg_);\n break;\n }\n returnObj['toVal'] = fromUnit.convertEqMol(fromVal, toUnit, charge);\n break;\n case 'eq|mol|mass':\n if (!fromUnit.isEqMolMassCommensurable(toUnit)) {\n returnObj['msg'].push(`Sorry. ${fromUnitCode} cannot be ` +\n `converted to ${toUnitCode}.`);\n break;\n }\n if (!molecularWeight) {\n returnObj['msg'].push(Ucum.needEqWeightMsg_);\n }\n if (!charge) {\n returnObj['msg'].push(Ucum.needEqChargeMsg_);\n }\n if (!returnObj['msg'].length) {\n returnObj['toVal'] = fromUnit.convertEqMolMass(fromVal, toUnit, molecularWeight, charge);\n }\n break;\n default:\n returnObj['msg'].push(\"Unknown conversion type. No conversion was attempted.\");\n }\n if (returnObj['msg'].length > msgCountBeforeConvert) {\n // If one or more failure messages are pushed into returnObj['msg']\n // in the switch statement, mark the status as 'failed'.\n returnObj['status'] = 'failed';\n } else {\n // Set the return object to show success.\n returnObj['status'] = 'succeeded';\n returnObj['fromUnit'] = fromUnit;\n returnObj['toUnit'] = toUnit;\n }\n } // end if we have the from and to units\n }\n\n return returnObj;\n\n } // end convertUnitTo\n\n\n /**\n * Converts the given unit string into its base units, their exponents, and\n * a magnitude, and returns that data.\n * @param fromUnit the unit string to be converted to base units information\n * @param fromVal the number of \"from\" units to be converted\n * @returns an object with the properties:\n * 'status' indicates whether the result succeeded. The value will be one of:\n * 'succeeded': the conversion was successfully calculated (which can be\n * true even if it was already in base units);\n * 'invalid': fromUnit is not a valid UCUM code;\n * 'failed': the conversion could not be made (e.g., if it is an \"arbitrary\" unit);\n * 'error': if an error occurred (an input or programming error)\n * 'msg': an array of messages (possibly empty) if the string is invalid or\n * an error occurred, indicating the problem, or a suggestion of a\n * substitution such as the substitution of 'G' for 'Gauss', or\n * an empty array if no messages were generated. There can also be a\n * message that is just informational or warning.\n * 'magnitude': the new value when fromVal units of fromUnits is expressed in the base units.\n * 'fromUnitIsSpecial': whether the input unit fromUnit is a \"special unit\"\n * as defined in UCUM. This means there is some function applied to convert\n * between fromUnit and the base units, so the returned magnitude is likely not\n * useful as a scale factor for other conversions (i.e., it only has validity\n * and usefulness for the input values that produced it).\n * 'unitToExp': a map of base units in fromUnit to their exponent\n */\n convertToBaseUnits(fromUnit, fromVal) {\n let retObj = {};\n this._checkFromVal(fromVal, retObj);\n if (!retObj.status) { // could be set to 'error' by _checkFromVal\n let inputUnitLookup = this.getSpecifiedUnit(fromUnit, 'validate');\n retObj = {status: inputUnitLookup.status == 'valid' ? 'succeeded' : inputUnitLookup.status};\n let unit = inputUnitLookup.unit;\n retObj.msg = inputUnitLookup.retMsg || [];\n if (!unit) {\n if (inputUnitLookup.retMsg?.length == 0)\n retObj.msg.push('Could not find unit information for '+fromUnit);\n }\n else if (unit.isArbitrary_) {\n retObj.msg.push('Arbitrary units cannot be converted to base units or other units.');\n retObj.status = 'failed';\n }\n else if (retObj.status == 'succeeded') {\n let unitToExp = {};\n let dimVec = unit.dim_?.dimVec_\n let baseUnitString = '1';\n if (dimVec) {\n let dimVecIndexToBaseUnit = UnitTables.getInstance().dimVecIndexToBaseUnit_;\n for (let i=0, len=dimVec.length; i<len; ++i) {\n let exp = dimVec[i];\n if (exp) {\n unitToExp[dimVecIndexToBaseUnit[i]] = exp;\n baseUnitString += '.' + dimVecIndexToBaseUnit[i] + exp;\n }\n }\n }\n\n // The unit might have a conversion function, which has to be applied; we\n // cannot just assume unit_.magnitude_ is the magnitude in base units.\n let retUnitLookup = this.getSpecifiedUnit(baseUnitString, 'validate');\n // There should not be any error in retUnitLookup, unless there is a bug.\n let retUnit = retUnitLookup.unit;\n if (retUnitLookup.status !== 'valid') {\n retObj.msg.push('Unable construct base unit string; tried '+baseUnitString);\n retObj.status = 'error';\n }\n else {\n try {\n retObj.magnitude = retUnit.convertFrom(fromVal, unit);\n }\n catch (e) {\n retObj.msg.push(e.toString());\n retObj.status = 'error';\n }\n if (retObj.status == 'succeeded') {\n retObj.unitToExp = unitToExp;\n retObj.fromUnitIsSpecial = unit.isSpecial_;\n }\n }\n }\n }\n return retObj;\n }\n\n\n /**\n * Checks the given value as to whether it is suitable as a \"from\" value in a\n * unit conversion. If it is not, the responseObj will have its status set\n * to 'error' and a message added.\n * @param fromVal The value to check\n * @param responseObj the object that will be updated if the value is not\n * usable.\n */\n _checkFromVal(fromVal, responseObj) {\n if (fromVal === null || isNaN(fromVal) || (typeof fromVal !== 'number' &&\n !intUtils_.isNumericString(fromVal))) {\n responseObj.status = 'error';\n if (!responseObj.msg)\n responseObj.msg = [];\n responseObj.msg.push('No \"from\" value, or an invalid \"from\" value, ' +\n 'was specified.');\n }\n }\n\n\n /**\n * This method accepts a term and looks for units that include it as\n * a synonym - or that include the term in its name.\n *\n * @param theSyn the term to search for\n * @returns a hash with up to three elements:\n * 'status' contains the status of the request, which can be 'error',\n * 'failed' or succeeded';\n * 'msg' which contains a message for an error or if no units were found; and\n * 'units' which is an array that contains one hash for each unit found:\n * 'code' is the unit's csCode_\n * 'name' is the unit's name_\n * 'guidance' is the unit's guidance_\n *\n */\n checkSynonyms(theSyn) {\n let retObj = {} ;\n if (theSyn === undefined || theSyn === null) {\n retObj['status'] = 'error';\n retObj['msg'] = 'No term specified for synonym search.'\n }\n else {\n retObj = intUtils_.getSynonyms(theSyn);\n } // end if a search synonym was supplied\n\n return retObj ;\n\n } // end checkSynonyms\n\n\n /**\n * This method parses a unit string to get (or try to get) the unit\n * represented by the string. It returns an error message if no string was specified\n * or if any errors were encountered trying to get the unit.\n *\n * @param uName the expression/string representing the unit\n * @param valConv indicates what type of request this is for - a request to\n * validate (pass in 'validate') or a request to convert (pass in 'convert')\n * @param suggest a boolean to indicate whether or not suggestions are\n * requested for a string that cannot be resolved to a valid unit;\n * true indicates suggestions are wanted; false indicates they are not,\n * and is the default if the parameter is not specified;\n * @returns a hash containing:\n * 'status' will be 'valid' (uName is a valid UCUM code), 'invalid'\n * (the uStr is not a valid UCUM code, and substitutions or\n * suggestions may or may not be returned, depending on what was\n * requested and found); or 'error' (an input or programming error\n * occurred);\n * 'unit' the unit object (or null if there were problems creating the\n * unit);\n * 'origString' the possibly updated unit string passed in;\n * 'retMsg' an array of user messages (informational, error or warning) if\n * any were generated (IF any were generated, otherwise will be an\n * empty array); and\n * 'suggestions' is an array of 1 or more hash objects. Each hash\n * contains three elements:\n * 'msg' which is a message indicating what unit expression the\n * suggestions are for;\n * 'invalidUnit' which is the unit expression the suggestions are\n * for; and\n * 'units' which is an array of data for each suggested unit found.\n * Each array will contain the unit code, the unit name and the\n * unit guidance (if any).\n * The return hash will not contain a suggestions array if a valid unit\n * was found or if suggestions were not requested and found.\n */\n getSpecifiedUnit(uName, valConv, suggest) {\n\n if (suggest === undefined)\n suggest = false ;\n\n let retObj = {};\n retObj['retMsg'] = [];\n\n if (!uName) {\n retObj['retMsg'].push('No unit string specified.');\n }\n else {\n let utab = UnitTables.getInstance();\n uName = uName.trim();\n\n // go ahead and just try using the name as the code. This may or may not\n // work, but if it does, it cuts out a lot of parsing.\n let theUnit = utab.getUnitByCode(uName);\n\n // If we found it, set the returned unit string to what was passed in;\n // otherwise try parsing as a unit string\n if (theUnit) {\n retObj['unit'] = theUnit ;\n retObj['origString'] = uName;\n }\n else {\n try {\n let resp = this.uStrParser_.parseString(uName, valConv, suggest);\n retObj['unit'] = resp[0];\n retObj['origString'] = resp[1];\n if (resp[2])\n retObj['retMsg'] = resp[2];\n retObj['suggestions'] = resp[3];\n }\n catch (err) {\n console.log(`Unit requested for unit string ${uName}.` +\n 'request unsuccessful; error thrown = ' + err.message);\n retObj['retMsg'].unshift(`${uName} is not a valid unit. ` +\n `${err.message}`);\n }\n } // end if the unit was not found as a unit name\n } // end if a unit expression was specified\n\n // Set the status field\n if (!retObj.unit) {\n // No unit was found; check whether origString has a value\n retObj.status = !retObj.origString ? 'error' : 'invalid';\n }\n else {\n // Check whether substitutions were made to the unit string in order to\n // find the unit\n retObj.status = retObj.origString === uName ? 'valid': 'invalid';\n }\n\n return retObj;\n\n } // end getSpecifiedUnit\n\n\n /**\n * This method retrieves a list of units commensurable, i.e., that can be\n * converted from and to, a specified unit. Returns an error if the \"from\"\n * unit cannot be found. If necessary, you can filter the list of units by\n * specifying a list of unit categories that should be in the resulting list.\n *\n * @param {string} fromName - the name/unit string of the \"from\" unit\n * @param {string[] | null} [categoryList] - the list of unit categories;\n * this parameter is optional, defaults to null if not specified;\n * possible list values: 'Clinical', 'Nonclinical', 'Obsolete', 'Constant'\n * @returns an array containing two elements;\n * first element is the list of commensurable units if any were found;\n * second element is an error message if the \"from\" unit is not found\n */\n commensurablesList(fromName, categoryList = null) {\n\n let retMsg = [];\n let commUnits = null ;\n let parseResp = this.getSpecifiedUnit(fromName, 'validate', false);\n let fromUnit = parseResp['unit'];\n if (parseResp['retMsg'].length > 0)\n retMsg = parseResp['retMsg'] ;\n if (!fromUnit) {\n retMsg.push(`Could not find unit ${fromName}.`);\n }\n else {\n let dimVec = null ;\n let fromDim = fromUnit.getProperty('dim_');\n if (!fromDim) {\n retMsg.push('No commensurable units were found for ' + fromName) ;\n }\n else {\n try {\n dimVec = fromDim.getProperty('dimVec_');\n }\n catch (err) {\n retMsg.push(err.message);\n if (err.message ===\n \"Dimension does not have requested property(dimVec_)\")\n dimVec = null;\n }\n if (dimVec) {\n let utab = UnitTables.getInstance();\n commUnits = utab.getUnitsByDimension(dimVec);\n if (categoryList) {\n commUnits = commUnits.filter((item) => {\n return categoryList.indexOf(item.category_) !== -1;\n });\n }\n }\n } // end if the from unit has a dimension vector\n } // end if we found a \"from\" unit\n return [commUnits , retMsg];\n } // end commensurablesList\n\n} // end UcumLhcUtils class\n\n\n/**\n * This function exists ONLY until the original UcumLhcUtils constructor\n * is called for the first time. It's defined here in case getInstance\n * is called before the constructor. This calls the constructor.\n *\n * The constructor redefines the getInstance function to return the\n * singleton UcumLhcUtils object. This is based on the UnitTables singleton\n * implementation; see more detail in the UnitTables constructor description.\n *\n * NO LONGER TRUE - not implemented as a singleton. This method retained to\n * avoid problems with calls to it that exist throughout the code.\n *\n * @return the (formerly singleton) UcumLhcUtils object.\n */\nUcumLhcUtils.getInstance = function(){\n return new UcumLhcUtils();\n} ;\n"],"mappings":";;;;;;AAOA,IAAAA,aAAA,GAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAoD,SAAAE,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,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,CAACE,QAAQ,IACpCH,QAAQ,CAACI,cAAc,IAAIH,MAAM,CAACG,cAAc,EAAE;MACpD;MACA;MACA;MACA;MACAF,cAAc,GAAG,QAAQ;IAC3B,CAAC,MACI,IAAIF,QAAQ,CAACI,cAAc,IAAIH,MAAM,CAACG,cAAc,EAAE;MACzD;MACA;MACA;MACAF,cAAc,GAAG,UAAU;IAC7B,CAAC,MACI,IAAIF,QAAQ,CAACG,QAAQ,IAAIF,MAAM,CAACE,QAAQ,EAAE;MAC7C;MACA;MACA;MACAD,cAAc,GAAG,SAAS;IAC5B,CAAC,MACI,IAAIF,QAAQ,CAACK,IAAI,CAACC,YAAY,CAAC,IAAI,CAACzB,aAAa,CAAC,IACjDoB,MAAM,CAACI,IAAI,CAACC,YAAY,CAAC,IAAI,CAACzB,aAAa,CAAC,EAAE;MAClD;MACA;MACA;MACAqB,cAAc,GAAG,QAAQ;IAC3B,CAAC,MACI;MACH;MACA;MACA;MACAA,cAAc,GAAG,aAAa;IAChC;IAEA,OAAOA,cAAc;EACvB,CAAC,CAAC;;EAGF;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,aAAaA,CAACC,YAAY,EAAEC,OAAO,EAAEC,UAAU,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;IAC7D,IAAI;MAACtB,OAAO,GAAG,KAAK;MAAEuB,eAAe,GAAG,IAAI;MAAEC,MAAM,GA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AACC,OAAO,CAAC;UACxB,IAAID,GAAG,CAACC,OAAO,KACb,qDAAqD,EACrDmB,MAAM,GAAG,IAAI;QACjB;QACA,IAAIA,MAAM,EAAE;UACV,IAAIoB,IAAI,GAAG5F,UAAU,CAACI,WAAW,CAAC,CAAC;UACnCkG,SAAS,GAAGV,IAAI,CAACa,mBAAmB,CAACjC,MAAM,CAAC;UAC5C,IAAI6B,YAAY,EAAE;YAChBC,SAAS,GAAGA,SAAS,CAACI,MAAM,CAAEC,IAAI,IAAK;cACrC,OAAON,YAAY,CAACO,OAAO,CAACD,IAAI,CAACE,SAAS,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC,CAAC;UACJ;QACF;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAACP,SAAS,EAAGjC,MAAM,CAAC;EAC7B,CAAC,CAAC;AAEJ,CAAC,CAAC;;AAGF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbAyC,OAAA,CAAA5G,YAAA,GAAAA,YAAA;AAcAA,YAAY,CAACE,WAAW,GAAG,YAAU;EACnC,OAAO,IAAIF,YAAY,CAAC,CAAC;AAC3B,CAAC","ignoreList":[]}
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Unit = void 0;
7
7
  var _ucumFunctions = _interopRequireDefault(require("./ucumFunctions.js"));
8
8
  var intUtils_ = _interopRequireWildcard(require("./ucumInternalUtils.js"));
9
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
10
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
11
  /**
13
12
  * This class represents one unit of measure. It includes
14
13
  * functions to cover constructor, accessor, and assignment tasks as