@lhncbc/ucum-lhc 7.1.0 → 7.1.2
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/browser-dist/ucum-lhc.min.js +1 -1
- package/browser-dist/ucum-lhc.min.js.map +1 -1
- package/package.json +1 -1
- package/source/ucumLhcUtils.js +114 -108
- package/source-cjs/config.js.map +1 -1
- package/source-cjs/dimension.js.map +1 -1
- package/source-cjs/jsonArrayPack.js.map +1 -1
- package/source-cjs/prefix.js.map +1 -1
- package/source-cjs/prefixTables.js.map +1 -1
- package/source-cjs/ucumFunctions.js.map +1 -1
- package/source-cjs/ucumInternalUtils.js.map +1 -1
- package/source-cjs/ucumJsonDefs.js.map +1 -1
- package/source-cjs/ucumLhcUtils.js +97 -87
- package/source-cjs/ucumLhcUtils.js.map +1 -1
- package/source-cjs/ucumPkg.js.map +1 -1
- package/source-cjs/ucumXmlDocument.js.map +1 -1
- package/source-cjs/unit.js.map +1 -1
- package/source-cjs/unitString.js.map +1 -1
- package/source-cjs/unitTables.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ucumXmlDocument.js","names":["Prefix","require","PrefixTables","Unit","UnitString","UnitTables","packArray","jsonfile","xmldoc","fs","essenceFile_","xmlInput_","UcumXmlDocument","constructor","data","readFileSync","XmlDocument","moleCodes_","equivCodes_","holdThis","prototype","exports","Error","self","getInstance","parseXml","parsePrefixes","childrenNamed","parseBaseUnits","parseUnitStrings","writeJsonFile","writeVersionText","prefixes","plen","length","p","curPfx","attrs","attr","Code","CODE","childNamed","val","pValNode","parseFloat","ptab","isDefined","newPref","add","unitNodes","blen","utab","b","curBUnit","dim","newUnit","addUnit","unitStrings","uStrParser","stopNow","alen","a","haveUnit","curUA","toUpperCase","sym","symVal","replace","trim","symI","toString","compressed","sub","sup","isMetric","isArbitrary","class","valNode","indexOf","isSpecial","funcNode","name","value","slashPos","ar","split","Math","pow","UNIT","substr","exp","parseInt","console","log","PI","retObj","parseString","ret","retString","retMsg","getProperty","newMag","err","message","uList","printUnits","writeFileSync","encoding","mode","flag","licenseText","pfxTabs","pfxArray","allPrefixesByCode","uTabs","uArray","allUnitsByDef","defsHash","dt","Date","spaces","rootNode","versionNum","version","revNum","revision","rootString","dateIdx","nextDolIdx","revDate","versionText"],"sources":["../source/ucumXmlDocument.js"],"sourcesContent":["/**\n * This class handles opening, reading and parsing the XML file of ucum\n * definitions (prefixes, base units, and unit atoms).\n *\n * @author Lee Mericle\n *\n */\nvar Prefix = require(\"./prefix.js\").Prefix;\nvar PrefixTables = require(\"./prefixTables.js\").PrefixTables;\nvar Unit = require(\"./unit.js\").Unit;\nvar UnitString = require(\"./unitString.js\").UnitString;\nvar UnitTables = require('./unitTables.js').UnitTables;\nvar packArray = require('./jsonArrayPack.js').packArray;\nvar jsonfile = require('jsonfile');\n\nvar xmldoc = require('xmldoc');\nvar fs = require('fs');\n\nvar essenceFile_ = '../data/ucum-essence.xml';\n\n/**\n * The full xml document\n * @type XmlDocument\n */\nvar xmlInput_ = null;\n\nexport class UcumXmlDocument {\n\n\n /**\n * Constructor. This reads the XML document (essenceFile_) into the\n * xmldoc object, which is an object used by the xmldoc class available\n * from GitHub - https://github.com/nfarina/xmldoc. The object provides\n * methods to read the file and access its contents.\n *\n */\n constructor() {\n // read the XML file and create an xmlDocument object from it.\n let data = fs.readFileSync(essenceFile_);\n xmlInput_ = new xmldoc.XmlDocument(data);\n\n // Array of unit codes in the ucum-essence.xml file that indicate a\n // mole based unit. The moleExp_ attribute for these units needs to be\n // set, but there doesn't seem to be an algorithmic way to find these.\n // Creation of unit objects after this file is processed will pick up\n // the moleExp_ value from the base mole unit, but the ones defined in\n // this file will not necessarily do that.\n this.moleCodes_ = ['mol', 'osm', 'kat', 'U' ];\n // Works similarly to the moleCodes_ array, but for units that represents\n // equivalent units. For unit codes in the equivCodes_ array, an equivalentExp_ \n // attribute flag will be set to 1. \n this.equivCodes_ = ['eq'];\n\n // Make this a singleton. See UnitTables constructor for details.\n\n let holdThis = UcumXmlDocument.prototype;\n UcumXmlDocument = function () {\n throw (new Error('UcumXmlDocument is a Singleton. ' +\n 'Use UcumXmlDocument.getInstance() instead.'));\n };\n if (exports)\n exports.UcumXmlDocument = UcumXmlDocument;\n UcumXmlDocument.prototype = holdThis;\n\n let self = this ;\n UcumXmlDocument.getInstance = function(){return self} ;\n }\n\n\n /**\n * This method controls parsing of the XML into objects used by this\n * program. It uses separate methods to parse the prefixes, the\n * base units, and the units.\n *\n * @returns nothing\n */\n parseXml() {\n\n this.parsePrefixes(xmlInput_.childrenNamed(\"prefix\"));\n this.parseBaseUnits(xmlInput_.childrenNamed(\"base-unit\")) ;\n this.parseUnitStrings(xmlInput_.childrenNamed(\"unit\")) ;\n\n // Create or replace the json file of the prefix and unit definitions\n this.writeJsonFile();\n this.writeVersionText();\n\n }\n\n\n /**\n * Creates prefix objects from the xml prefix nodes passed in and gets\n * them added to the prefix tables.\n *\n * @params prefixes the array of prefix nodes from the xml file, in the\n * order in which the nodes are defined in that file.\n *\n * @returns nothing\n */\n parsePrefixes(prefixes) {\n\n\n let plen = prefixes.length ;\n\n for (let p = 0; p < plen; p++) {\n let curPfx = prefixes[p];\n let attrs = {} ;\n\n attrs[\"code_\"] = curPfx.attr.Code;\n attrs[\"ciCode_\"] = curPfx.attr.CODE;\n attrs[\"name_\"] = curPfx.childNamed('name').val;\n attrs[\"printSymbol_\"] = curPfx.childNamed('printSymbol').val;\n\n // Set the prefix value. If there is a <sup> element in the\n // value node, then this is a base 10 based prefix (10 to the x power).\n // Set the value to 10 taken to the indicated power.\n // Otherwise this is not 10 based and the value contains the\n // actual value for the prefix.\n let pValNode = curPfx.childNamed('value') ;\n attrs[\"value_\"] = null;\n attrs[\"exp_\"] = pValNode.childNamed('sup');\n if (attrs[\"exp_\"] != null) {\n attrs[\"exp_\"] = attrs[\"exp_\"].val;\n // Use parseFloat('1eSOMETHING') instead of Math.pow() to avoid\n // small number changes like 1.0000000000000001e-21. See LF-2830.\n // attrs[\"value_\"] = Math.pow(10, attrs[\"exp_\"]);\n attrs[\"value_\"] = parseFloat(`1e${attrs[\"exp_\"]}`);\n }\n else {\n attrs[\"value_\"] = pValNode.val;\n attrs[\"exp_\"] = null;\n }\n\n // Make sure the prefix has not already been created. If it hasn't,\n // create the prefix object and then add it to the prefix tables.\n let ptab = PrefixTables.getInstance();\n if (ptab.isDefined(attrs[\"code_\"])) {\n throw(new Error('Prefix constructor called for prefix already ' +\n `defined; code = ${attrs[\"code_\"]}`));\n }\n else {\n let newPref = new Prefix(attrs);\n ptab.add(newPref);\n }\n }\n } // end parsePrefixes\n\n\n /**\n * Creates base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitNodes the array of base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseBaseUnits(unitNodes) {\n let blen = unitNodes.length ;\n let utab = UnitTables.getInstance() ;\n for (let b = 0; b < blen; b++) {\n let curBUnit = unitNodes[b];\n let attrs = {} ;\n attrs['isBase_'] = true ;\n attrs['name_'] = curBUnit.childNamed('name').val ;\n attrs['csCode_'] = curBUnit.attr.Code ;\n attrs['ciCode_'] = curBUnit.attr.CODE ;\n attrs['property_'] = curBUnit.childNamed('property').val;\n attrs['variable_'] = curBUnit.attr.dim ;\n attrs['printSymbol_'] = curBUnit.childNamed('printSymbol').val;\n attrs['dim_'] = b ;\n attrs['source_'] = 'UCUM';\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit) ;\n }\n } // end parseBaseUnits\n\n\n /**\n * Creates non-base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitStrings the array of non-base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseUnitStrings(unitStrings) {\n\n let utab = UnitTables.getInstance() ;\n let uStrParser = UnitString.getInstance();\n let stopNow = false ;\n let alen = unitStrings.length ;\n for (let a = 0; a < alen && !stopNow; a++) {\n let haveUnit = true;\n let curUA = unitStrings[a];\n let attrs = {};\n attrs['isBase_'] = false;\n attrs['source_'] = 'UCUM';\n attrs['name_'] = curUA.childNamed('name').val;\n attrs['csCode_'] = curUA.attr.Code;\n if (curUA.attr.CODE)\n attrs['ciCode_'] = curUA.attr.CODE;\n else\n attrs['ciCode_'] = curUA.attr.Code.toUpperCase();\n attrs['property_'] = curUA.childNamed('property').val;\n if (curUA.childNamed('printSymbol')) {\n let sym = curUA.childNamed('printSymbol') ;\n let symVal = sym.val;\n symVal = symVal.replace(/\\n/g, \"\");\n symVal = symVal.trim();\n let symI = sym.childNamed('i');\n if (symI)\n //symVal = '<i>' + symI.val + '</>';\n symVal = symI.toString({compressed:true});\n let sub = sym.childNamed('sub');\n let sup = sym.childNamed('sup');\n if (sub)\n symVal += sub.toString({compressed:true});\n if (sup)\n symVal += sup.toString({compressed:true});\n\n attrs['printSymbol_'] = symVal;\n }\n if (curUA.attr.isMetric === \"yes\")\n attrs['isMetric_'] = true ;\n else\n attrs['isMetric_'] = false ;\n if (curUA.attr.isArbitrary)\n attrs['isArbitrary_'] = true ;\n else\n attrs['isArbitrary_'] = false ;\n if (curUA.attr.class) {\n attrs['class_'] = curUA.attr.class;\n }\n let valNode = curUA.childNamed('value');\n // Note: This currently works as a boolean flag,\n // but it should be used to represent the dimensionality\n // of the unit as an integer instead.\n if (this.moleCodes_.indexOf(curUA.attr.Code) !== -1)\n attrs['moleExp_'] = 1;\n else\n attrs['moleExp_'] = 0;\n // Adds a flag similar to how moleExp_ works, but for units \n // that are equivalent. Note that ideally this should also\n // take values other than 1 or 0, but for now it is a boolean \n // flag.\n if (this.equivCodes_.indexOf(curUA.attr.Code) !== -1) {\n attrs['equivalentExp_'] = 1;\n }\n\n\n // Process special units\n if (curUA.attr.isSpecial) {\n attrs['isSpecial_'] = curUA.attr.isSpecial === \"yes\";\n let funcNode = valNode.childNamed('function');\n attrs['cnv_'] = funcNode.attr.name;\n attrs['csUnitString_'] = funcNode.attr.Unit;\n if (attrs['csUnitString_'] === '1') {\n attrs['baseFactor_'] = 1 ;\n }\n else if (attrs['csCode_'] === '[pH]') {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value) ;\n }\n else {\n let slashPos = attrs['csUnitString_'].indexOf('/');\n let ar = [];\n\n // unit string = K/9 or K/4 or m2/s4/Hz\n if (slashPos >= 0) {\n ar = attrs['csUnitString_'].split('/');\n }\n // unit string = K/9 or K/4\n if ((slashPos >= 0) && (ar.length === 2)) {\n attrs['csUnitString_'] = ar[0];\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value/ar[1]);\n }\n // unit string = 10*-5.Pa\n else if (attrs['csCode_'] === 'B[SPL]') {\n attrs['baseFactor_'] = Math.pow(10, -5) * 2 ;\n attrs['csUnitString_'] = \"Pa\" ;\n }\n // unit string = m1/s4/Hz, K, deg, V, mV, uV, nV, W, kW\n else {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value);\n }\n } // end if the unit string is not 1\n } // end if the unit is special\n\n else {\n // what I'm calling the unit string is the string that defines the\n // unit based on other units, e.g., rad2 (radian squared) to define\n // a steradian unit. It's not necessarily a proper base unit, although\n // it ultimately builds on base units.\n attrs['csUnitString_'] = valNode.attr.Unit;\n attrs['ciUnitString_'] = valNode.attr.UNIT;\n\n // what I'm calling the factor here (string and number versions)\n // is the magnitude used in conjunction with the unit string to define\n // the new unit, e.g., 3 for a yard that is based in the definition\n // of feet.\n\n attrs['baseFactorStr_'] = valNode.attr.value;\n if (attrs['csCode_'] === '[pi]')\n attrs['baseFactor_'] = parseFloat(attrs['baseFactorStr_']);\n else if (valNode.childNamed('sup')) {\n attrs['baseFactor_'] = parseFloat(valNode.attr.value) ;\n }\n else {\n attrs['baseFactor_'] = parseFloat(valNode.val);\n }\n } // end if this is not a special unit\n\n // Arbitrary units are defined in the UCUM spec as \"not of any\n // specific dimension and are not commensurable with any other\n // unit\" (3.2.24). All arbitrary units in the units definition\n // XML file currently have a unit string of 1 and a base factor of 1\n // except the \"international unit\" with a code of [IU]. Its\n // unit string is the \"international unit\" with a code of [iU],\n // which is also an arbitrary unit - with a unit string of 1.\n // So I am assuming [IU] is just another code for the same unit.\n if (attrs['isArbitrary_'] === true) {\n attrs['magnitude_'] = 1;\n attrs['dim_'] = null;\n }\n\n // units with class = \"dimless\" don't have dimension arrays.\n // They're things like the number pi or the number 10 or percent.\n // Haven't figured out how to handle them yet.\n else if (attrs['class_'] === 'dimless' ||\n attrs['csCode_'] === 'mol') {\n attrs['dim_'] = null ;\n // figure the magnitude based on the unit string\n // if it's 1, the magnitude is the value specified for\n // the base factor, e.g., 3.141592653589793238462 ... for pi\n if (attrs['csUnitString_'] === '1') {\n attrs['magnitude_'] = attrs['baseFactor_'];\n }\n // else if the unit string starts with 10*, the magnitude is\n // 10 to the power specified following 10* e.g., unit = 10*-2\n // for the \"%\" unit. Except for the mole, which is that\n // multiplied by the base factor, which in this case (only,\n // I think) is not 1.\n else if (attrs['csUnitString_'].substr(0,3) == \"10*\") {\n let exp = parseInt(attrs['csUnitString_'].substr(3));\n attrs['magnitude_'] = Math.pow(10, exp) ;\n if (attrs['baseFactor_'] !== 1) {\n attrs['magnitude_'] *= attrs['baseFactor_'];\n }\n }\n // else I don't know what it is.\n else {\n attrs['defError_'] = true ;\n console.log('unexpected dimless unit definition, unit code ' +\n 'is ' + attrs['csCode_']) ;\n }\n } // end if this is a unit with class = dimless\n\n // Handle carat of gold alloys - which doesn't get a dimension\n //\n else if (attrs['csCode_'] === \"[car_Au]\") {\n attrs['magnitude_'] = 1/24 ;\n attrs['dim_'] = null ;\n }\n else {\n\n // Make sure there's a unit string to base the new unit on. There\n // should be, but I'm just checking here to make sure. And omit\n // ones with a unit string of 1. That won't do us any good.\n if (attrs['csUnitString_'] && attrs['csUnitString_'] !== '1' &&\n attrs['csUnitString_'] !== 1) {\n\n haveUnit = false;\n // Handle some special cases\n // 1. the Oersted unit, whose string is /[pi].A/m and whose\n // value is 250. Set the baseFactor to 250/[pi] and\n // the unit string to A/m\n if (attrs['csCode_'] === 'Oe') {\n attrs['baseFactor_'] = 250 / Math.PI;\n attrs['csUnitString_'] = \"A/m\"\n }\n // 2. Strings that start with '/'. Set the function to\n // the inverse function and trim the '/' off the front\n // of the string.\n else if (attrs['csUnitString_'][0] === '/') {\n attrs['cnv_'] = 'inv';\n attrs['csUnitString_'] = attrs['csUnitString_'].substr(1);\n }\n // 3. the Svedberg unit, whose string is 10*-13.s. Set the\n // base factor to 10*-13 and the unit string to s.\n else if (attrs['csCode_'] === '[S]') {\n attrs['baseFactor_'] = Math.pow(10, -13);\n attrs['csUnitString_'] = 's';\n }\n // 4. permeability of vaccuum - code [mu_0], unit given is\n // 4.[pi].10*-7.N/A2\n else if (attrs['csCode_'] === '[mu_0]') {\n attrs['baseFactor_'] = 4 * Math.PI * Math.pow(10, -7);\n attrs['csUnitString_'] = 'N/A2';\n }\n // The unit string parser will use the unit(s) named in the\n // string to create a new unit with the appropriate dimension\n // object and magnitude before it's multiplied by the one\n // specified in the input node.\n try {\n let retObj = uStrParser.parseString(attrs['csUnitString_'],\n 'validate', false);\n let ret = retObj[0];\n let retString = retObj[1];\n let retMsg = retObj[2];\n\n // Get the dimension object and magnitude (and adjust by\n // specified magnitude factor) from the unit created and\n // assign them to the attributes we'll use to create the\n // unit for this listing.\n if (ret) {\n attrs['dim_'] = ret.getProperty('dim_');\n let newMag = ret.getProperty('magnitude_');\n newMag *= attrs['baseFactor_'];\n attrs['magnitude_'] = newMag;\n haveUnit = true ;\n }\n // if there's no unit, report an error\n else {\n attrs['defError_'] = true;\n console.log(`unit definition error; code = ${attrs['csCode_']}; `+\n `msg = ${retMsg}`);\n attrs['dim_'] = null;\n attrs['magnitude_'] = null;\n }\n }\n catch(err) {\n console.log('error thrown from unit parsing code for unit name ' +\n attrs['name_'] + '\\n' + err.message);\n stopNow = true;\n }\n } // end if there is a unit string to parse\n } // end if this is not a dimless unit\n\n if (haveUnit) {\n // Now create the unit we want based on the attributes we've\n // accumulated from the xml input and from figuring the dimension\n // and magnitude. Add it to the unit tables\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit);\n\n // for now, create a list of the units created and save it to a file\n // for debugging. This is a temporary file.\n let uList = utab.printUnits();\n fs.writeFileSync('UnitsList.txt', uList,\n {encoding: 'utf8', mode: 0o666, flag: 'w'});\n } // end if have a parsed unit\n } // end for a => - to alen\n\n } // end parseUnitStrings\n\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates or replace the file \"ucumDefs.json\" in the data directory.\n */\n writeJsonFile() {\n\n let licenseText = \"The following data (prefixes and units) was generated \" +\n \"by the UCUM LHC code from the UCUM data and selected \" +\n \"LOINC combinations of UCUM units. The license for \" +\n \"the UCUM LHC code (demo and library code as well as \" +\n \"the combined units) is located at \" +\n \"https://github.com/lhncbc/ucum-lhc/blob/LICENSE.md.\" ;\n let pfxTabs = PrefixTables.getInstance() ;\n let pfxArray = pfxTabs.allPrefixesByCode();\n let uTabs = UnitTables.getInstance();\n let uArray = uTabs.allUnitsByDef();\n\n let defsHash = { 'license' : licenseText,\n 'prefixes' : packArray(pfxArray),\n 'units' : packArray(uArray)};\n let dt = new Date();\n jsonfile.writeFileSync('../data/ucumDefs.json',\n defsHash,\n {spaces: 2, encoding: 'utf8', mode: 0o644, flag: 'w'});\n jsonfile.writeFileSync('../data/ucumDefs.min.json',\n defsHash,\n {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeJsonFile\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates the file in the data directory and appends the\n * current Date object value to \"ucumDefs\" so that this does not run\n * into problems with a previously existing file.\n */\n writeVersionText() {\n\n let rootNode = xmlInput_;\n let versionNum = rootNode.attr.version;\n let revNum = rootNode.attr.revision;\n revNum = revNum.replace('$Revision:', '');\n revNum = revNum.replace('$', '');\n revNum = revNum.trim();\n let rootString = rootNode.toString({compressed:true});\n let dateIdx = rootString.indexOf('$Date:');\n rootString = rootString.substr(dateIdx + 6);\n let nextDolIdx = rootString.indexOf('$');\n let revDate = rootString.substr(0, nextDolIdx ).replace('$','');\n revDate = revDate.trim();\n let versionText = `version ${versionNum}, revision ${revNum}, ` +\n `dated ${revDate}`;\n\n fs.writeFileSync('../data/ucumEssenceVersion.txt',\n versionText, {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeVersionText\n\n} // end UcumXmlDocument\n\n\n/**\n * This function exists ONLY until the original UcumXmlDocument 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 UcumXmlDocument object. This is based on the UnitTables singleton\n * implementation; see more detail in the UnitTables constructor description.\n *\n * @return the singleton UcumXmlDocument object.\n */\nUcumXmlDocument.getInstance = function(){\n return new UcumXmlDocument();\n}\n\n// Perform the first request for the document object, to get the\n// getInstance method set.\nUcumXmlDocument.getInstance();\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,MAAM,GAAGC,OAAO,CAAC,aAAa,CAAC,CAACD,MAAM;AAC1C,IAAIE,YAAY,GAAGD,OAAO,CAAC,mBAAmB,CAAC,CAACC,YAAY;AAC5D,IAAIC,IAAI,GAAGF,OAAO,CAAC,WAAW,CAAC,CAACE,IAAI;AACpC,IAAIC,UAAU,GAAGH,OAAO,CAAC,iBAAiB,CAAC,CAACG,UAAU;AACtD,IAAIC,UAAU,GAAGJ,OAAO,CAAC,iBAAiB,CAAC,CAACI,UAAU;AACtD,IAAIC,SAAS,GAAGL,OAAO,CAAC,oBAAoB,CAAC,CAACK,SAAS;AACvD,IAAIC,QAAQ,GAAGN,OAAO,CAAC,UAAU,CAAC;AAElC,IAAIO,MAAM,GAAGP,OAAO,CAAC,QAAQ,CAAC;AAC9B,IAAIQ,EAAE,GAAGR,OAAO,CAAC,IAAI,CAAC;AAEtB,IAAIS,YAA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IAAG,GACrD,SAAQK,OAAQ,EAAC;IAE3BxH,EAAE,CAACiG,aAAa,CAAC,gCAAgC,EAC/CwB,WAAW,EAAE;MAACvB,QAAQ,EAAE,MAAM;MAAEC,IAAI,EAAE,KAAK;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAC;EAC5D,CAAC,CAAC;AAEJ,CAAC,CAAC;;AAGF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVAxF,OAAA,CAAAT,eAAA,GAAAA,eAAA;AAWAA,eAAe,CAACY,WAAW,GAAG,YAAU;EACtC,OAAO,IAAIZ,eAAe,CAAC,CAAC;AAC9B,CAAC;;AAED;AACA;AACAA,eAAe,CAACY,WAAW,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"ucumXmlDocument.js","names":["Prefix","require","PrefixTables","Unit","UnitString","UnitTables","packArray","jsonfile","xmldoc","fs","essenceFile_","xmlInput_","UcumXmlDocument","constructor","data","readFileSync","XmlDocument","moleCodes_","equivCodes_","holdThis","prototype","exports","Error","self","getInstance","parseXml","parsePrefixes","childrenNamed","parseBaseUnits","parseUnitStrings","writeJsonFile","writeVersionText","prefixes","plen","length","p","curPfx","attrs","attr","Code","CODE","childNamed","val","pValNode","parseFloat","ptab","isDefined","newPref","add","unitNodes","blen","utab","b","curBUnit","dim","newUnit","addUnit","unitStrings","uStrParser","stopNow","alen","a","haveUnit","curUA","toUpperCase","sym","symVal","replace","trim","symI","toString","compressed","sub","sup","isMetric","isArbitrary","class","valNode","indexOf","isSpecial","funcNode","name","value","slashPos","ar","split","Math","pow","UNIT","substr","exp","parseInt","console","log","PI","retObj","parseString","ret","retString","retMsg","getProperty","newMag","err","message","uList","printUnits","writeFileSync","encoding","mode","flag","licenseText","pfxTabs","pfxArray","allPrefixesByCode","uTabs","uArray","allUnitsByDef","defsHash","dt","Date","spaces","rootNode","versionNum","version","revNum","revision","rootString","dateIdx","nextDolIdx","revDate","versionText"],"sources":["../source/ucumXmlDocument.js"],"sourcesContent":["/**\n * This class handles opening, reading and parsing the XML file of ucum\n * definitions (prefixes, base units, and unit atoms).\n *\n * @author Lee Mericle\n *\n */\nvar Prefix = require(\"./prefix.js\").Prefix;\nvar PrefixTables = require(\"./prefixTables.js\").PrefixTables;\nvar Unit = require(\"./unit.js\").Unit;\nvar UnitString = require(\"./unitString.js\").UnitString;\nvar UnitTables = require('./unitTables.js').UnitTables;\nvar packArray = require('./jsonArrayPack.js').packArray;\nvar jsonfile = require('jsonfile');\n\nvar xmldoc = require('xmldoc');\nvar fs = require('fs');\n\nvar essenceFile_ = '../data/ucum-essence.xml';\n\n/**\n * The full xml document\n * @type XmlDocument\n */\nvar xmlInput_ = null;\n\nexport class UcumXmlDocument {\n\n\n /**\n * Constructor. This reads the XML document (essenceFile_) into the\n * xmldoc object, which is an object used by the xmldoc class available\n * from GitHub - https://github.com/nfarina/xmldoc. The object provides\n * methods to read the file and access its contents.\n *\n */\n constructor() {\n // read the XML file and create an xmlDocument object from it.\n let data = fs.readFileSync(essenceFile_);\n xmlInput_ = new xmldoc.XmlDocument(data);\n\n // Array of unit codes in the ucum-essence.xml file that indicate a\n // mole based unit. The moleExp_ attribute for these units needs to be\n // set, but there doesn't seem to be an algorithmic way to find these.\n // Creation of unit objects after this file is processed will pick up\n // the moleExp_ value from the base mole unit, but the ones defined in\n // this file will not necessarily do that.\n this.moleCodes_ = ['mol', 'osm', 'kat', 'U' ];\n // Works similarly to the moleCodes_ array, but for units that represents\n // equivalent units. For unit codes in the equivCodes_ array, an equivalentExp_ \n // attribute flag will be set to 1. \n this.equivCodes_ = ['eq'];\n\n // Make this a singleton. See UnitTables constructor for details.\n\n let holdThis = UcumXmlDocument.prototype;\n UcumXmlDocument = function () {\n throw (new Error('UcumXmlDocument is a Singleton. ' +\n 'Use UcumXmlDocument.getInstance() instead.'));\n };\n if (exports)\n exports.UcumXmlDocument = UcumXmlDocument;\n UcumXmlDocument.prototype = holdThis;\n\n let self = this ;\n UcumXmlDocument.getInstance = function(){return self} ;\n }\n\n\n /**\n * This method controls parsing of the XML into objects used by this\n * program. It uses separate methods to parse the prefixes, the\n * base units, and the units.\n *\n * @returns nothing\n */\n parseXml() {\n\n this.parsePrefixes(xmlInput_.childrenNamed(\"prefix\"));\n this.parseBaseUnits(xmlInput_.childrenNamed(\"base-unit\")) ;\n this.parseUnitStrings(xmlInput_.childrenNamed(\"unit\")) ;\n\n // Create or replace the json file of the prefix and unit definitions\n this.writeJsonFile();\n this.writeVersionText();\n\n }\n\n\n /**\n * Creates prefix objects from the xml prefix nodes passed in and gets\n * them added to the prefix tables.\n *\n * @params prefixes the array of prefix nodes from the xml file, in the\n * order in which the nodes are defined in that file.\n *\n * @returns nothing\n */\n parsePrefixes(prefixes) {\n\n\n let plen = prefixes.length ;\n\n for (let p = 0; p < plen; p++) {\n let curPfx = prefixes[p];\n let attrs = {} ;\n\n attrs[\"code_\"] = curPfx.attr.Code;\n attrs[\"ciCode_\"] = curPfx.attr.CODE;\n attrs[\"name_\"] = curPfx.childNamed('name').val;\n attrs[\"printSymbol_\"] = curPfx.childNamed('printSymbol').val;\n\n // Set the prefix value. If there is a <sup> element in the\n // value node, then this is a base 10 based prefix (10 to the x power).\n // Set the value to 10 taken to the indicated power.\n // Otherwise this is not 10 based and the value contains the\n // actual value for the prefix.\n let pValNode = curPfx.childNamed('value') ;\n attrs[\"value_\"] = null;\n attrs[\"exp_\"] = pValNode.childNamed('sup');\n if (attrs[\"exp_\"] != null) {\n attrs[\"exp_\"] = attrs[\"exp_\"].val;\n // Use parseFloat('1eSOMETHING') instead of Math.pow() to avoid\n // small number changes like 1.0000000000000001e-21. See LF-2830.\n // attrs[\"value_\"] = Math.pow(10, attrs[\"exp_\"]);\n attrs[\"value_\"] = parseFloat(`1e${attrs[\"exp_\"]}`);\n }\n else {\n attrs[\"value_\"] = pValNode.val;\n attrs[\"exp_\"] = null;\n }\n\n // Make sure the prefix has not already been created. If it hasn't,\n // create the prefix object and then add it to the prefix tables.\n let ptab = PrefixTables.getInstance();\n if (ptab.isDefined(attrs[\"code_\"])) {\n throw(new Error('Prefix constructor called for prefix already ' +\n `defined; code = ${attrs[\"code_\"]}`));\n }\n else {\n let newPref = new Prefix(attrs);\n ptab.add(newPref);\n }\n }\n } // end parsePrefixes\n\n\n /**\n * Creates base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitNodes the array of base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseBaseUnits(unitNodes) {\n let blen = unitNodes.length ;\n let utab = UnitTables.getInstance() ;\n for (let b = 0; b < blen; b++) {\n let curBUnit = unitNodes[b];\n let attrs = {} ;\n attrs['isBase_'] = true ;\n attrs['name_'] = curBUnit.childNamed('name').val ;\n attrs['csCode_'] = curBUnit.attr.Code ;\n attrs['ciCode_'] = curBUnit.attr.CODE ;\n attrs['property_'] = curBUnit.childNamed('property').val;\n attrs['variable_'] = curBUnit.attr.dim ;\n attrs['printSymbol_'] = curBUnit.childNamed('printSymbol').val;\n attrs['dim_'] = b ;\n attrs['source_'] = 'UCUM';\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit) ;\n }\n } // end parseBaseUnits\n\n\n /**\n * Creates non-base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitStrings the array of non-base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseUnitStrings(unitStrings) {\n\n let utab = UnitTables.getInstance() ;\n let uStrParser = UnitString.getInstance();\n let stopNow = false ;\n let alen = unitStrings.length ;\n for (let a = 0; a < alen && !stopNow; a++) {\n let haveUnit = true;\n let curUA = unitStrings[a];\n let attrs = {};\n attrs['isBase_'] = false;\n attrs['source_'] = 'UCUM';\n attrs['name_'] = curUA.childNamed('name').val;\n attrs['csCode_'] = curUA.attr.Code;\n if (curUA.attr.CODE)\n attrs['ciCode_'] = curUA.attr.CODE;\n else\n attrs['ciCode_'] = curUA.attr.Code.toUpperCase();\n attrs['property_'] = curUA.childNamed('property').val;\n if (curUA.childNamed('printSymbol')) {\n let sym = curUA.childNamed('printSymbol') ;\n let symVal = sym.val;\n symVal = symVal.replace(/\\n/g, \"\");\n symVal = symVal.trim();\n let symI = sym.childNamed('i');\n if (symI)\n //symVal = '<i>' + symI.val + '</>';\n symVal = symI.toString({compressed:true});\n let sub = sym.childNamed('sub');\n let sup = sym.childNamed('sup');\n if (sub)\n symVal += sub.toString({compressed:true});\n if (sup)\n symVal += sup.toString({compressed:true});\n\n attrs['printSymbol_'] = symVal;\n }\n if (curUA.attr.isMetric === \"yes\")\n attrs['isMetric_'] = true ;\n else\n attrs['isMetric_'] = false ;\n if (curUA.attr.isArbitrary)\n attrs['isArbitrary_'] = true ;\n else\n attrs['isArbitrary_'] = false ;\n if (curUA.attr.class) {\n attrs['class_'] = curUA.attr.class;\n }\n let valNode = curUA.childNamed('value');\n // Note: This currently works as a boolean flag,\n // but it should be used to represent the dimensionality\n // of the unit as an integer instead.\n if (this.moleCodes_.indexOf(curUA.attr.Code) !== -1)\n attrs['moleExp_'] = 1;\n else\n attrs['moleExp_'] = 0;\n // Adds a flag similar to how moleExp_ works, but for units \n // that are equivalent. Note that ideally this should also\n // take values other than 1 or 0, but for now it is a boolean \n // flag.\n if (this.equivCodes_.indexOf(curUA.attr.Code) !== -1) {\n attrs['equivalentExp_'] = 1;\n }\n\n\n // Process special units\n if (curUA.attr.isSpecial) {\n attrs['isSpecial_'] = curUA.attr.isSpecial === \"yes\";\n let funcNode = valNode.childNamed('function');\n attrs['cnv_'] = funcNode.attr.name;\n attrs['csUnitString_'] = funcNode.attr.Unit;\n if (attrs['csUnitString_'] === '1') {\n attrs['baseFactor_'] = 1 ;\n }\n else if (attrs['csCode_'] === '[pH]') {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value) ;\n }\n else {\n let slashPos = attrs['csUnitString_'].indexOf('/');\n let ar = [];\n\n // unit string = K/9 or K/4 or m2/s4/Hz\n if (slashPos >= 0) {\n ar = attrs['csUnitString_'].split('/');\n }\n // unit string = K/9 or K/4\n if ((slashPos >= 0) && (ar.length === 2)) {\n attrs['csUnitString_'] = ar[0];\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value/ar[1]);\n }\n // unit string = 10*-5.Pa\n else if (attrs['csCode_'] === 'B[SPL]') {\n attrs['baseFactor_'] = Math.pow(10, -5) * 2 ;\n attrs['csUnitString_'] = \"Pa\" ;\n }\n // unit string = m1/s4/Hz, K, deg, V, mV, uV, nV, W, kW\n else {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value);\n }\n } // end if the unit string is not 1\n } // end if the unit is special\n\n else {\n // what I'm calling the unit string is the string that defines the\n // unit based on other units, e.g., rad2 (radian squared) to define\n // a steradian unit. It's not necessarily a proper base unit, although\n // it ultimately builds on base units.\n attrs['csUnitString_'] = valNode.attr.Unit;\n attrs['ciUnitString_'] = valNode.attr.UNIT;\n\n // what I'm calling the factor here (string and number versions)\n // is the magnitude used in conjunction with the unit string to define\n // the new unit, e.g., 3 for a yard that is based in the definition\n // of feet.\n\n attrs['baseFactorStr_'] = valNode.attr.value;\n if (attrs['csCode_'] === '[pi]')\n attrs['baseFactor_'] = parseFloat(attrs['baseFactorStr_']);\n else if (valNode.childNamed('sup')) {\n attrs['baseFactor_'] = parseFloat(valNode.attr.value) ;\n }\n else {\n attrs['baseFactor_'] = parseFloat(valNode.val);\n }\n } // end if this is not a special unit\n\n // Arbitrary units are defined in the UCUM spec as \"not of any\n // specific dimension and are not commensurable with any other\n // unit\" (3.2.24). All arbitrary units in the units definition\n // XML file currently have a unit string of 1 and a base factor of 1\n // except the \"international unit\" with a code of [IU]. Its\n // unit string is the \"international unit\" with a code of [iU],\n // which is also an arbitrary unit - with a unit string of 1.\n // So I am assuming [IU] is just another code for the same unit.\n if (attrs['isArbitrary_'] === true) {\n attrs['magnitude_'] = 1;\n attrs['dim_'] = null;\n }\n\n // units with class = \"dimless\" don't have dimension arrays.\n // They're things like the number pi or the number 10 or percent.\n // Haven't figured out how to handle them yet.\n else if (attrs['class_'] === 'dimless' ||\n attrs['csCode_'] === 'mol') {\n attrs['dim_'] = null ;\n // figure the magnitude based on the unit string\n // if it's 1, the magnitude is the value specified for\n // the base factor, e.g., 3.141592653589793238462 ... for pi\n if (attrs['csUnitString_'] === '1') {\n attrs['magnitude_'] = attrs['baseFactor_'];\n }\n // else if the unit string starts with 10*, the magnitude is\n // 10 to the power specified following 10* e.g., unit = 10*-2\n // for the \"%\" unit. Except for the mole, which is that\n // multiplied by the base factor, which in this case (only,\n // I think) is not 1.\n else if (attrs['csUnitString_'].substr(0,3) == \"10*\") {\n let exp = parseInt(attrs['csUnitString_'].substr(3));\n attrs['magnitude_'] = Math.pow(10, exp) ;\n if (attrs['baseFactor_'] !== 1) {\n attrs['magnitude_'] *= attrs['baseFactor_'];\n }\n }\n // else I don't know what it is.\n else {\n attrs['defError_'] = true ;\n console.log('unexpected dimless unit definition, unit code ' +\n 'is ' + attrs['csCode_']) ;\n }\n } // end if this is a unit with class = dimless\n\n // Handle carat of gold alloys - which doesn't get a dimension\n //\n else if (attrs['csCode_'] === \"[car_Au]\") {\n attrs['magnitude_'] = 1/24 ;\n attrs['dim_'] = null ;\n }\n else {\n\n // Make sure there's a unit string to base the new unit on. There\n // should be, but I'm just checking here to make sure. And omit\n // ones with a unit string of 1. That won't do us any good.\n if (attrs['csUnitString_'] && attrs['csUnitString_'] !== '1' &&\n attrs['csUnitString_'] !== 1) {\n\n haveUnit = false;\n // Handle some special cases\n // 1. the Oersted unit, whose string is /[pi].A/m and whose\n // value is 250. Set the baseFactor to 250/[pi] and\n // the unit string to A/m\n if (attrs['csCode_'] === 'Oe') {\n attrs['baseFactor_'] = 250 / Math.PI;\n attrs['csUnitString_'] = \"A/m\"\n }\n // 2. Strings that start with '/'. Set the function to\n // the inverse function and trim the '/' off the front\n // of the string.\n else if (attrs['csUnitString_'][0] === '/') {\n attrs['cnv_'] = 'inv';\n attrs['csUnitString_'] = attrs['csUnitString_'].substr(1);\n }\n // 3. the Svedberg unit, whose string is 10*-13.s. Set the\n // base factor to 10*-13 and the unit string to s.\n else if (attrs['csCode_'] === '[S]') {\n attrs['baseFactor_'] = Math.pow(10, -13);\n attrs['csUnitString_'] = 's';\n }\n // 4. permeability of vaccuum - code [mu_0], unit given is\n // 4.[pi].10*-7.N/A2\n else if (attrs['csCode_'] === '[mu_0]') {\n attrs['baseFactor_'] = 4 * Math.PI * Math.pow(10, -7);\n attrs['csUnitString_'] = 'N/A2';\n }\n // The unit string parser will use the unit(s) named in the\n // string to create a new unit with the appropriate dimension\n // object and magnitude before it's multiplied by the one\n // specified in the input node.\n try {\n let retObj = uStrParser.parseString(attrs['csUnitString_'],\n 'validate', false);\n let ret = retObj[0];\n let retString = retObj[1];\n let retMsg = retObj[2];\n\n // Get the dimension object and magnitude (and adjust by\n // specified magnitude factor) from the unit created and\n // assign them to the attributes we'll use to create the\n // unit for this listing.\n if (ret) {\n attrs['dim_'] = ret.getProperty('dim_');\n let newMag = ret.getProperty('magnitude_');\n newMag *= attrs['baseFactor_'];\n attrs['magnitude_'] = newMag;\n haveUnit = true ;\n }\n // if there's no unit, report an error\n else {\n attrs['defError_'] = true;\n console.log(`unit definition error; code = ${attrs['csCode_']}; `+\n `msg = ${retMsg}`);\n attrs['dim_'] = null;\n attrs['magnitude_'] = null;\n }\n }\n catch(err) {\n console.log('error thrown from unit parsing code for unit name ' +\n attrs['name_'] + '\\n' + err.message);\n stopNow = true;\n }\n } // end if there is a unit string to parse\n } // end if this is not a dimless unit\n\n if (haveUnit) {\n // Now create the unit we want based on the attributes we've\n // accumulated from the xml input and from figuring the dimension\n // and magnitude. Add it to the unit tables\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit);\n\n // for now, create a list of the units created and save it to a file\n // for debugging. This is a temporary file.\n let uList = utab.printUnits();\n fs.writeFileSync('UnitsList.txt', uList,\n {encoding: 'utf8', mode: 0o666, flag: 'w'});\n } // end if have a parsed unit\n } // end for a => - to alen\n\n } // end parseUnitStrings\n\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates or replace the file \"ucumDefs.json\" in the data directory.\n */\n writeJsonFile() {\n\n let licenseText = \"The following data (prefixes and units) was generated \" +\n \"by the UCUM LHC code from the UCUM data and selected \" +\n \"LOINC combinations of UCUM units. The license for \" +\n \"the UCUM LHC code (demo and library code as well as \" +\n \"the combined units) is located at \" +\n \"https://github.com/lhncbc/ucum-lhc/blob/LICENSE.md.\" ;\n let pfxTabs = PrefixTables.getInstance() ;\n let pfxArray = pfxTabs.allPrefixesByCode();\n let uTabs = UnitTables.getInstance();\n let uArray = uTabs.allUnitsByDef();\n\n let defsHash = { 'license' : licenseText,\n 'prefixes' : packArray(pfxArray),\n 'units' : packArray(uArray)};\n let dt = new Date();\n jsonfile.writeFileSync('../data/ucumDefs.json',\n defsHash,\n {spaces: 2, encoding: 'utf8', mode: 0o644, flag: 'w'});\n jsonfile.writeFileSync('../data/ucumDefs.min.json',\n defsHash,\n {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeJsonFile\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates the file in the data directory and appends the\n * current Date object value to \"ucumDefs\" so that this does not run\n * into problems with a previously existing file.\n */\n writeVersionText() {\n\n let rootNode = xmlInput_;\n let versionNum = rootNode.attr.version;\n let revNum = rootNode.attr.revision;\n revNum = revNum.replace('$Revision:', '');\n revNum = revNum.replace('$', '');\n revNum = revNum.trim();\n let rootString = rootNode.toString({compressed:true});\n let dateIdx = rootString.indexOf('$Date:');\n rootString = rootString.substr(dateIdx + 6);\n let nextDolIdx = rootString.indexOf('$');\n let revDate = rootString.substr(0, nextDolIdx ).replace('$','');\n revDate = revDate.trim();\n let versionText = `version ${versionNum}, revision ${revNum}, ` +\n `dated ${revDate}`;\n\n fs.writeFileSync('../data/ucumEssenceVersion.txt',\n versionText, {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeVersionText\n\n} // end UcumXmlDocument\n\n\n/**\n * This function exists ONLY until the original UcumXmlDocument 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 UcumXmlDocument object. This is based on the UnitTables singleton\n * implementation; see more detail in the UnitTables constructor description.\n *\n * @return the singleton UcumXmlDocument object.\n */\nUcumXmlDocument.getInstance = function(){\n return new UcumXmlDocument();\n}\n\n// Perform the first request for the document object, to get the\n// getInstance method set.\nUcumXmlDocument.getInstance();\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,MAAM,GAAGC,OAAO,CAAC,aAAa,CAAC,CAACD,MAAM;AAC1C,IAAIE,YAAY,GAAGD,OAAO,CAAC,mBAAmB,CAAC,CAACC,YAAY;AAC5D,IAAIC,IAAI,GAAGF,OAAO,CAAC,WAAW,CAAC,CAACE,IAAI;AACpC,IAAIC,UAAU,GAAGH,OAAO,CAAC,iBAAiB,CAAC,CAACG,UAAU;AACtD,IAAIC,UAAU,GAAGJ,OAAO,CAAC,iBAAiB,CAAC,CAACI,UAAU;AACtD,IAAIC,SAAS,GAAGL,OAAO,CAAC,oBAAoB,CAAC,CAACK,SAAS;AACvD,IAAIC,QAAQ,GAAGN,OAAO,CAAC,UAAU,CAAC;AAElC,IAAIO,MAAM,GAAGP,OAAO,CAAC,QAAQ,CAAC;AAC9B,IAAIQ,EAAE,GAAGR,OAAO,CAAC,IAAI,CAAC;AAEtB,IAAIS,YAAY,GAAG,0BAA0B;;AAE7C;AACA;AACA;AACA;AACA,IAAIC,SAAS,GAAG,IAAI;AAEb,MAAMC,eAAe,CAAC;EAG3B;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EAAG;IACZ;IACA,IAAIC,IAAI,GAAGL,EAAE,CAACM,YAAY,CAACL,YAAY,CAAC;IACxC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GF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVAxF,OAAA,CAAAT,eAAA,GAAAA,eAAA;AAWAA,eAAe,CAACY,WAAW,GAAG,YAAU;EACtC,OAAO,IAAIZ,eAAe,CAAC,CAAC;AAC9B,CAAC;;AAED;AACA;AACAA,eAAe,CAACY,WAAW,CAAC,CAAC","ignoreList":[]}
|
package/source-cjs/unit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unit.js","names":["_ucumFunctions","_interopRequireDefault","require","intUtils_","_interopRequireWildcard","_getRequireWildcardCache","WeakMap","cache","obj","__esModule","default","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Ucum","Dimension","UnitTables","isInteger","Unit","constructor","attrs","isBase_","name_","csCode_","ciCode_","property_","magnitude_","undefined","dim_","Array","printSymbol_","class_","isMetric_","variable_","cnv_","cnvPfx_","isSpecial_","isArbitrary_","moleExp_","equivalentExp_","synonyms_","source_","loincProperty_","category_","guidance_","csUnitString_","ciUnitString_","baseFactorStr_","baseFactor_","defError_","assignUnity","assignZero","assignVals","vals","uKey","charAt","length","Error","clone","retUnit","getOwnPropertyNames","forEach","val","assign","unit2","equals","fullEquals","thisAttr","keys","sort","u2Attr","keyLen","match","k","getProperty","propertyName","uProp","convertFrom","num","fromUnit","newNum","isMolMassCommensurable","needMoleWeightMsg_","isNull","fromCnv","fromMag","x","fromFunc","funcs","forName","cnvFrom","toFunc","cnvTo","convertTo","toUnit","convertCoherent","f_from","mutateCoherent","i","max","getMax","elem","getElementAt","tabs","_getUnitTables","uA","getUnitsByDimension","name","convertMolMass","amt","molecularWeight","molPowersToConvert","avoNum","getUnitByCode","moleUnitFactor","Math","pow","convertEqMass","charge","massPowersToConvert","equivalentMass","avogadroNumber","equivalents","moleFactor","adjustedEquivalents","convertEqMolMass","eqPowersToConvert","molAmt","d","getMassDimensionIndex","isEquivalentUnit","isMolarUnit","convertEqMol","mutateRatio","multiplyThis","s","mulVal","toString","_concatStrs","multiplyThese","isZero","dimVec_","add","resetFieldsForDerivedUnit","divide","invertString","sub","minus","invert","theString","stringRep","replace","substr","str1","operator","str2","startChar","endChar","_buildOneString","str","ret","isNumericString","endsWith","test","power","p","uStr","uArray","arLen","un","nun","parseInt","uLen","u","uChar","exp","join","mul","unit1Dim","setElementAt","unit2Dim","isEqMassCommensurable","isEqMolCommensurable","unit1Sum","unit2Sum","isEqMolMassCommensurable","getInstance","exports"],"sources":["../source/unit.js"],"sourcesContent":["\n/**\n * This class represents one unit of measure. It includes\n * functions to cover constructor, accessor, and assignment tasks as\n * well as operators to calculate multiplication, division and raising\n * to a power.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\nvar Ucum = require('./config.js').Ucum;\nvar Dimension = require('./dimension.js').Dimension;\nimport funcs from \"./ucumFunctions.js\";\nvar UnitTables;\n\nvar isInteger = require(\"is-integer\");\nimport * as intUtils_ from \"./ucumInternalUtils.js\";\n\nexport class Unit {\n\n /**\n * Constructor.\n *\n * @param attrs an optional parameter that may be:\n * a string, which is parsed by the unit parser, which creates\n * the unit from the parsed string; or\n * a hash containing all or some values for the attributes of\n * the unit, where the keys are the attribute names, without a\n * trailing underscore, e.g., name instead of name_; or\n * null, in which case an empty hash is created and used to\n * set the values forthe attributes.\n * If a hash (empty or not) is used, attributes for which no value\n * is specified are assigned a default value.\n *\n */\n constructor(attrs = {}) {\n\n // Process the attrs hash passed in, which may be empty.\n // Create and assign values (from the attrs hash or defaults) to all\n // attributes. From Class Declarations in Understanding ECMAScript,\n // https://leanpub.com/understandinges6/read/#leanpub-auto-class-declarations,\n // \"Own properties, properties that occur on the instance rather than the\n // prototype, can only be created inside of a class constructor or method.\n // It's recommended to create all possible own properties inside of the\n // constructor function so there's a single place that's responsible for\n // all of them.\"\n\n /*\n * Flag indicating whether or not this is a base unit\n */\n this.isBase_ = attrs['isBase_'] || false ;\n\n /*\n * The unit name, e.g., meter\n */\n this.name_ = attrs['name_'] || '';\n\n /*\n * The unit's case-sensitive code, e.g., m\n */\n this.csCode_ = attrs['csCode_'] || '';\n\n /*\n * The unit's case-insensitive code, e.g., M\n */\n this.ciCode_ = attrs['ciCode_'] || '';\n\n /*\n * The unit's property, e.g., length\n */\n this.property_ = attrs['property_'] || '';\n\n /*\n * The magnitude of the unit, e.g., 3600/3937 for a yard,\n * where a yard - 3600/3973 * m(eter). The Dimension\n * property specifies the meter - which is the unit on which\n * a yard is based, and this magnitude specifies how to figure\n * this unit based on the base unit.\n */\n this.magnitude_ = attrs['magnitude_'] || 1;\n\n /*\n * The Dimension object of the unit\n */\n if (attrs['dim_'] === undefined || attrs['dim_'] === null) {\n this.dim_ = new Dimension();\n }\n // When the unit data stored in json format is reloaded, the dimension data\n // is recognized as a a hash, not as a Dimension object.\n else if (attrs['dim_']['dimVec_'] !== undefined) {\n this.dim_ = new Dimension(attrs['dim_']['dimVec_']) ;\n }\n else if (attrs['dim_'] instanceof Dimension) {\n this.dim_ = attrs['dim_'];\n }\n else if (attrs['dim_'] instanceof Array || isInteger(attrs['dim_'])) {\n this.dim_ = new Dimension(attrs['dim_']) ;\n }\n else {\n this.dim_ = new Dimension();\n }\n /*\n * The print symbol of the unit, e.g., m\n */\n this.printSymbol_ = attrs['printSymbol_'] || null;\n\n /*\n * The class of the unit, where given, e.g., dimless\n */\n this.class_ = attrs['class_'] || null;\n\n /*\n * A flag indicating whether or not the unit is metric\n */\n this.isMetric_ = attrs['isMetric_'] || false;\n\n /*\n * The \"variable\" - which I think is used only for base units\n * The symbol for the variable as used in equations, e.g., s for distance\n */\n this.variable_ = attrs['variable_'] || null ; // comes from 'dim' in XML\n\n /*\n * The conversion function\n */\n this.cnv_ = attrs['cnv_'] || null;\n\n /*\n * The conversion prefix\n */\n this.cnvPfx_ = attrs['cnvPfx_'] || 1;\n\n /*\n * Flag indicating whether or not this is a \"special\" unit, i.e., is\n * constructed using a function specific to the measurement, e.g.,\n * fahrenheit and celsius\n */\n this.isSpecial_ = attrs['isSpecial_'] || false ;\n\n /*\n * Flag indicating whether or not this is an arbitrary unit\n */\n this.isArbitrary_ = attrs['isArbitrary_'] || false;\n\n /*\n * Integer indicating what level of exponent applies to a mole-based portion\n * of the unit. So, for the unit \"mol\", this will be 1. For \"mol2\" this\n * will be 2. For \"1/mol\" this will be -1. Any unit that does not include\n * a mole will have a 0 in this field. This is used to determine\n * commensurability for mole<->mass conversions.\n */\n this.moleExp_ = attrs['moleExp_'] || 0;\n\n /**\n * Flag indicating whether or not this is a equivalent mole unit\n */\n this.equivalentExp_ = attrs['equivalentExp_'] || 0;\n\n /*\n * Added when added LOINC list of units\n * synonyms are used by the autocompleter to enhance lookup capabilities\n * while source says where the unit first shows up. Current sources are\n * UCUM - which are units from the unitsofmeasure.org list and LOINC -\n * which are units from the LOINC data.\n */\n this.synonyms_ = attrs['synonyms_'] || null ;\n this.source_ = attrs['source_'] || null ;\n this.loincProperty_ = attrs['loincProperty_'] || null;\n this.category_ = attrs['category_'] || null;\n this.guidance_ = attrs['guidance_'] || null;\n\n /*\n * Used to compute dimension; storing for now until I complete\n * unit definition parsing\n */\n /*\n * Case sensitive (cs) and case insensitive (ci) base unit strings,\n * includes exponent and prefix if applicable - specified in\n * <value Unit=x UNIT=X value=\"nnn\">nnn</value> -- the unit part --\n * in the ucum-essence.xml file, and may be specified by a user\n * when requesting conversion or validation of a unit string. The\n * magnitude (base factor) is used with this to determine the new unit.\n * For example, a Newton (unit code N) is created from the string\n * kg.m/s2, and the value of 1 (base factor defined below). An hour\n * (unit code h) is created from the unit min (minute) with a value\n * of 60.\n */\n this.csUnitString_ = attrs['csUnitString_'] || null ;\n this.ciUnitString_ = attrs['ciUnitString_'] || null ;\n\n /*\n * String and numeric versions of factor applied to unit specified in\n * <value Unit=x UNIT=X value=\"nnn\">nnn</value> -- the value part\n */\n this.baseFactorStr_ = attrs['baseFactorStr_'] || null;\n this.baseFactor_ = attrs['baseFactor_'] || null;\n\n /*\n * Flag used to indicate units where the definition process failed\n * when parsing units from the official units definitions file\n * (currently using the ucum-essence.xml file). We keep these\n * so that we can use them to at least validate them as valid\n * units, but we don't try to convert them. This is temporary\n * and only to account for instances where the code does not\n * take into account various special cases in the xml file.\n *\n * This is NOT used when trying to validate a unit string\n * submitted during a conversion or validation attempt.\n */\n this.defError_ = attrs['defError_'] || false ;\n\n\n } // end constructor\n\n\n /**\n * Assign the unity (= dimensionless unit 1) to this unit.\n *\n * @return this unit\n */\n assignUnity() {\n this.name_ = \"\" ;\n this.magnitude_ = 1 ;\n if (!this.dim_)\n this.dim_ = new Dimension();\n this.dim_.assignZero() ;\n this.cnv_ = null ;\n this.cnvPfx_ = 1 ;\n return this;\n\n } // end assignUnity\n\n\n /**\n * This assigns one or more values, as provided in the hash passed in,\n * to this unit.\n *\n * @param vals hash of values to be assigned to the attributes\n * specified by the key(s), which should be the attribute\n * name without the trailing underscore, e.g., name instead\n * of name_.\n * @return nothing\n */\n assignVals(vals) {\n for (let key in vals) {\n let uKey = !(key.charAt(key.length - 1)) === '_' ? key + '_' : key ;\n if (this.hasOwnProperty(uKey))\n this[uKey] = vals[key];\n else\n throw(new Error(`Parameter error; ${key} is not a property of a Unit`));\n }\n } // end assignVals\n\n\n /**\n * This creates a clone of this unit.\n *\n * @return the clone\n */\n clone() {\n let retUnit = new Unit() ;\n Object.getOwnPropertyNames(this).forEach(val => {\n if (val === 'dim_') {\n if (this['dim_'])\n retUnit['dim_'] = this['dim_'].clone();\n else\n retUnit['dim_'] = null;\n }\n else\n retUnit[val] = this[val];\n });\n return retUnit ;\n\n } // end clone\n\n\n /**\n * This assigns all properties of a unit passed to it to this unit.\n *\n * @param unit2 the unit whose properties are to be assigned to this one.\n * @return nothing; this unit is updated\n */\n assign(unit2) {\n Object.getOwnPropertyNames(unit2).forEach(val => {\n if (val === 'dim_') {\n if (unit2['dim_'])\n this['dim_'] = unit2['dim_'].clone();\n else\n this['dim_'] = null;\n }\n else {\n this[val] = unit2[val];\n }\n });\n } // end assign\n\n\n /**\n * This determines whether or not object properties of the unit\n * passed in are equal to the corresponding properties in this unit.\n * The following properties are the only ones checked:\n * magnitude_, dim_, cnv_ and cnvPfx_\n *\n * @param unit2 the unit whose properties are to be checked.\n * @return boolean indicating whether or not they match\n */\n equals(unit2) {\n\n return (this.magnitude_ === unit2.magnitude_ &&\n this.cnv_ === unit2.cnv_ &&\n this.cnvPfx_ === unit2.cnvPfx_ &&\n ((this.dim_ === null && unit2.dim_ === null) ||\n this.dim_.equals(unit2.dim_)));\n\n } // end equals\n\n\n /**\n * This method compares every attribute of two objects to determine\n * if they all match.\n *\n * @param unit2 the unit that is to be compared to this unit\n * @return boolean indicating whether or not every attribute matches\n */\n fullEquals(unit2) {\n\n let thisAttr = Object.keys(this).sort();\n let u2Attr = Object.keys(unit2).sort();\n\n let keyLen = thisAttr.length ;\n let match = (keyLen === u2Attr.length);\n\n // check each attribute. Dimension objects have to checked using\n // the equals function of the Dimension class.\n for (let k = 0; k < keyLen && match; k++) {\n if (thisAttr[k] === u2Attr[k]) {\n if (thisAttr[k] === 'dim_')\n match = this.dim_.equals(unit2.dim_);\n else\n match = this[thisAttr[k]] === unit2[thisAttr[k]];\n }\n else\n match = false ;\n } // end do for each key and attribute\n return match ;\n }// end of fullEquals\n\n\n /**\n * This returns the value of the property named by the parameter\n * passed in.\n *\n * @param propertyName name of the property to be returned, with\n * or without the trailing underscore.\n * @return the requested property, if found for this unit\n * @throws an error if the property is not found for this unit\n */\n getProperty(propertyName) {\n let uProp = propertyName.charAt(propertyName.length - 1) === '_' ? propertyName :\n propertyName + '_' ;\n return this[uProp] ;\n\n } // end getProperty\n\n\n /**\n * Takes a measurement consisting of a number of units and a unit and returns\n * the equivalent number of this unit. So, 15 mL would translate\n * to 1 tablespoon if this object is a tablespoon.\n *\n * Note that the number returned may not be what is normally expected.\n * For example, converting 10 Celsius units to Fahrenheit would \"normally\"\n * return a value of 50. But in this case you'll get back something like\n * 49.99999999999994.\n *\n * If either unit is an arbitrary unit an exception is raised.\n *\n * @param num the magnitude for the unit to be translated (e.g. 15 for 15 mL)\n * @param fromUnit the unit to be translated to one of this type (e.g. a mL unit)\n *\n * @return the number of converted units (e.g. 1 for 1 tablespoon)\n * @throws an error if the dimension of the fromUnit differs from this unit's\n * dimension\n */\n convertFrom(num, fromUnit) {\n let newNum = 0.0 ;\n\n if (this.isArbitrary_)\n throw (new Error(`Attempt to convert to arbitrary unit \"${this.csCode_}\"`));\n if (fromUnit.isArbitrary_)\n throw (new Error(`Attempt to convert arbitrary unit \"${fromUnit.csCode_}\"`));\n\n // reject request if both units have dimensions that are not equal\n if (fromUnit.dim_ && this.dim_ && !(fromUnit.dim_.equals(this.dim_))) {\n // check first to see if a mole<->mass conversion is appropriate\n if (this.isMolMassCommensurable(fromUnit)) {\n throw(new Error(Ucum.needMoleWeightMsg_));\n }\n else {\n throw(new Error(`Sorry. ${fromUnit.csCode_} cannot be converted ` +\n `to ${this.csCode_}.`));\n }\n }\n // reject request if there is a \"from\" dimension but no \"to\" dimension\n if (fromUnit.dim_ && (!this.dim_ || this.dim_.isNull())) {\n throw(new Error(`Sorry. ${fromUnit.csCode_} cannot be converted ` +\n `to ${this.csCode_}.`));\n }\n\n // reject request if there is a \"to\" dimension but no \"from\" dimension\n if (this.dim_ && (!fromUnit.dim_ || fromUnit.dim_.isNull())) {\n throw(new Error(`Sorry. ${fromUnit.csCode_} cannot be converted ` +\n `to ${this.csCode_}.`));\n }\n\n let fromCnv = fromUnit.cnv_ ;\n let fromMag = fromUnit.magnitude_ ;\n\n let x;\n if (fromCnv != null) {\n // turn num * fromUnit.magnitude into its ratio scale equivalent,\n // e.g., convert Celsius to Kelvin\n let fromFunc = funcs.forName(fromCnv);\n x = fromFunc.cnvFrom(num * fromUnit.cnvPfx_) * fromMag;\n //x = fromFunc.cnvFrom(num * fromMag) * fromUnit.cnvPfx_;\n }\n else {\n x = num * fromMag;\n }\n\n if (this.cnv_ != null) {\n // turn mag * origUnit on ratio scale into a non-ratio unit,\n // e.g. convert Kelvin to Fahrenheit\n let toFunc = funcs.forName(this.cnv_);\n newNum = toFunc.cnvTo(x / this.magnitude_) / this.cnvPfx_;\n }\n else {\n newNum = x / this.magnitude_;\n }\n\n return newNum;\n\n } // end convertFrom\n\n\n /**\n * Takes a number and a target unit and returns the number for a measurement\n * of this unit that corresponds to the number of the target unit passed in.\n * So, 1 tablespoon (where this unit represents a tablespoon) would translate\n * to 15 mL.\n *\n * See the note on convertFrom about return values.\n *\n * @param mag the magnitude for this unit (e.g. 1 for 1 tablespoon)\n * @param toUnit the unit to which this unit is to be translated\n * (e.g. an mL unit)\n *\n * @return the converted number value (e.g. 15 mL)\n * @throws an error if the dimension of the toUnit differs from this unit's\n * dimension\n */\n convertTo(num, toUnit) {\n\n return toUnit.convertFrom(num, this) ;\n\n } // end convertTo\n\n\n /**\n * Takes a given number of this unit returns the number of this unit\n * if it is converted into a coherent unit. Does not change this unit.\n *\n * If this is a coherent unit already, just gives back the number\n * passed in.\n *\n * @param num the number for the coherent version of this unit\n * @return the number for the coherent version of this unit\n */\n convertCoherent(num) {\n\n // convert mag' * u' into canonical number * u on ratio scale\n if(this.cnv_ !== null)\n num = this.cnv_.f_from(num / this.cnvPfx_) * this.magnitude_;\n\n return num;\n\n } // end convertCoherent\n\n\n /**\n * Mutates this unit into a coherent unit and converts a given number of\n * units to the appropriate value for this unit as a coherent unit\n *\n * @param num the number for this unit before conversion\n * @return the number of this unit after conversion\n * @throws an error if the dimensions differ\n */\n mutateCoherent(num) {\n\n // convert mu' * u' into canonical mu * u on ratio scale\n num = this.convertCoherent(num) ;\n\n // mutate to coherent unit\n this.magnitude_ = 1;\n this.cnv_ = null;\n this.cnvPfx_ = 1;\n this.name_ = \"\";\n\n // build a name as a term of coherent base units\n // This is probably ALL WRONG and a HORRIBLE MISTAKE\n // but until we figure out what the heck the name being\n // built here really is, it will have to stay.\n for (let i = 0, max = Dimension.getMax(); i < max; i++) {\n let elem = this.dim_.getElementAt(i);\n let tabs = this._getUnitTables();\n let uA = tabs.getUnitsByDimension(new Dimension(i));\n if(uA == null)\n throw(new Error(`Can't find base unit for dimension ${i}`));\n this.name_ = uA.name + elem;\n }\n return num;\n\n } // end mutateCoherent\n\n\n /**\n * This function converts between mol and mass (in either direction)\n * using the molecular weight of the substance. It assumes that the\n * isMolMassCommensurable\" function has been called to check that the units are\n * commensurable.\n *\n * @param amt the quantity of this unit to be converted\n * @param toUnit the target/to unit for which the converted # is wanted\n * @param molecularWeight the molecular weight of the substance for which the\n * conversion is being made\n * @return the equivalent amount in toUnit\n */\n convertMolMass(amt, toUnit, molecularWeight) {\n // In the calculations below we are treating \"molecularWeight\" (measured in\n // a.m.u) as the molar weight (measured in g/mol). The values are the same,\n // though the units differ.\n\n // Determine the number of powers of mol we have to convert to mass.\n // Typically this will be just 1, or -1, but not necessarily. If it is a\n // negative number, then we are really converting mass to moles.\n const molPowersToConvert = this.moleExp_ - toUnit.moleExp_;\n // A simple mole unit has a magnitude of avogadro's number. Get that\n // number now (since not everyone agrees on what it is, and what is\n // being used in this system might change).\n let tabs = this._getUnitTables();\n let avoNum = tabs.getUnitByCode('mol').magnitude_ ;\n // For each molPowersToConvert, we need to multiply the mol unit by the\n // molar weight (g/mol) and divide by avoNum (1/mol) to get a weight per\n // molecule. (Note that the magnitude_ of each unit will contain factors of\n // avoNum, of which we are thus getting rid of some).\n let moleUnitFactor = Math.pow(molecularWeight/avoNum, molPowersToConvert);\n // The new value is proportional to this.magnitude_, amt, and\n // moleUnitFactor, and inversely proportional to toUnit_.magnitude.\n return this.magnitude_/toUnit.magnitude_ * moleUnitFactor * amt;\n } // end convertMolMass\n\n\n /**\n * This function converts between equivalants and mass (in either direction)\n * using the charge of the substance. It assumes that the\n * isEqMassCommensurable\" function has been called to check that the units are\n * commensurable.\n *\n * @param {number} amt - The amount of this unit to be converted.\n * @param {object} toUnit - The target/to unit for which the converted number is wanted.\n * @param {number} molecularWeight - The molecular weight of the substance for which the conversion is being made.\n * @param {number} charge - The absolute value of the charge of the substance for which the conversion is being made.\n * @returns {number} - The amount in the specified toUnit.\n */\n convertEqMass(amt, toUnit, molecularWeight, charge) {\n // Determine the number of powers of mass we have to convert to equivalents.\n // Typically this will be just 1, or -1, but not necessarily. If it is a\n // negative number, then we are converting in the opposite direciton.\n // Because the units are presumed commensurable, we can use the\n // equivalentExp_ instead of the mass dimension.\n const massPowersToConvert = toUnit.equivalentExp_ - this.equivalentExp_ ;\n // Calculate equivalent mass by dividing molecular weight by charge\n let equivalentMass = molecularWeight / charge;\n // Get Avogadro's number from the unit tables\n let avogadroNumber = this._getUnitTables().getUnitByCode('mol').magnitude_ ;\n // Calculate equivalents by dividing mass by equivalent mass, for each\n // power to be converted.\n let equivalents = this.magnitude_ * amt / Math.pow(equivalentMass, massPowersToConvert);\n // Calculate mole factor by dividing the magnitude of the equivalent unit by\n // Avogadro's number. toUnit may have a prefix (e.g. meq) and we need to adjust for that, for\n // each massPowersToConvert.\n let moleFactor = toUnit.magnitude_ / Math.pow(avogadroNumber, massPowersToConvert);\n // Adjust equivalents by dividing by the mole factor\n let adjustedEquivalents = equivalents / moleFactor;\n // Return the adjusted equivalents\n return adjustedEquivalents;\n } // end convertMassToEq\n\n\n /**\n * Converts a unit with eq/mol/mass to another unit with eq/mol/mass. It\n * assumes the units an commensurable, which can be checked via\n * isEqMolMassCommensurable. It also assumes that the powers of eq/mol/mass\n * are different between the two units; otherwise it would be more efficient\n * to call one of the other convert... functions.\n *\n * @param {number} amt - The amount of this unit to be converted.\n * @param {object} toUnit - The target/to unit for which the converted number is wanted.\n * @param {number} molecularWeight - The molecular weight of the substance for which the conversion is being made.\n * @param {number} charge - The absolute value of the charge of the substance for which the conversion is being made.\n * @returns {number} - The equivalent amount in the specified equivalent unit.\n */\n convertEqMolMass(amt, toUnit, molecularWeight, charge) {\n // Handle the equivalent differences. It important for the following\n // calculations (for consistency) that we consider the difference in\n // equivalent powers and not mol powers, so we are not calling\n // convertEqToMol, in case its implementation changes.\n // See convertEqToMol for details. One difference is that we do not scale\n // by magnitude_ until the end.\n const eqPowersToConvert = this.equivalentExp_ - toUnit.equivalentExp_;\n const molAmt = amt / Math.pow(charge, eqPowersToConvert);\n // Now for the mol/mass converstion part, we consider only the mass power\n // differences, and not the mol power differences (which were partially\n // handled in the eq/mol step above).\n // Again, see convertMolToMass for details on the calculations.\n const tabs = this._getUnitTables();\n const d = tabs.getMassDimensionIndex();\n const massPowersToConvert = this.dim_.getElementAt(d) - toUnit.dim_.getElementAt(d);\n const molPowersToConvert = -massPowersToConvert; // so the formulas follow convertMolToMass\n const avoNum = tabs.getUnitByCode('mol').magnitude_ ;\n let moleUnitFactor = Math.pow(molecularWeight/avoNum, molPowersToConvert);\n return this.magnitude_/toUnit.magnitude_ * moleUnitFactor * molAmt;\n }\n\n\n /**\n * Checks if the given unit is an equivalent unit.\n *\n * Note: equivalent units are also be molar units, so a unit can return true for\n * both isEquivalentUnit and isMolarUnit.\n *\n * @returns {boolean} - Returns true if the unit is an equivalent unit, false otherwise.\n */\n isEquivalentUnit() {\n return this.equivalentExp_ !== 0;\n } // end isEquivalentUnit\n\n /**\n * Checks if the given unit is a molar unit.\n *\n * @returns {boolean} - Returns true if the unit is a molar unit, false otherwise.\n */\n isMolarUnit() {\n return this.moleExp_ !== 0;\n } // end isMolarUnit\n\n\n /**\n * This function converts between equivalants and moles (in either direction)\n * using the charge of the substance. It assumes that the\n * isEqMolCommensurable\" function has been called to check that the units are\n * commensurable.\n\n * As with the other \"convert\" functions, it assumes the appropriate\n * \"is...Commensurable\" function has been called.\n *\n * @param {number} amt - The amount of this unit for which the conversion is being made.\n * @param {object} toUnit - The target unit for which the converted number is wanted.\n * @param {number} charge - The absolute value of the charge of the substance for which the conversion is being made.\n * @return {number} - The amount in molToUnit.\n */\n convertEqMol(amt, toUnit, charge) {\n // Determine the number of powers of eq we have to convert to mol.\n // Typically this will be just 1, or -1, but not necessarily. If it is a\n // negative number, then we are really converting mol to eq.\n const eqPowersToConvert = this.equivalentExp_ - toUnit.equivalentExp_;\n\n // A simple mole unit has a magnitude of avogadro's number.\n // So does 'eq' (equivalent) because in ucum it is defined as 1 mol, though\n // that does not account for the charge. Therefore, we don't need to\n // account for that factor in this conversion.\n\n // The conversion from equivalents to moles is based on the principle that\n // one equivalent is equal to 1/charge moles (per eqPowersToConvert).\n // The relative magnitude is accounted for via the current unit's magnitude\n // (this.magnitude_) and the target unit's magnitude (molToUnit.magnitude_)\n // For each eqPowersToConvert, we need to divide by the charge.\n return amt * (this.magnitude_ / toUnit.magnitude_) / Math.pow(charge, eqPowersToConvert);\n } // end convertEqMol\n\n\n /**\n * Mutates this unit into a unit on a ratio scale and converts a specified\n * number of units to an appropriate value for this converted unit\n *\n * @param num the number of this unit before it's converted\n * @return the magnitude of this unit after it's converted\n * @throw an error if the dimensions differ\n */\n mutateRatio(num) {\n if (this.cnv_ == null)\n return this.mutateCoherent(num);\n else\n return num;\n\n } // end mutateRatio\n\n\n /**\n * Multiplies this unit with a scalar. Special meaning for\n * special units so that (0.1*B) is 1 dB.\n *\n * This function DOES NOT modify this unit.\n *\n * @param s the value by which this unit is to be multiplied\n * @return a copy this unit multiplied by s\n * */\n multiplyThis(s) {\n\n let retUnit = this.clone() ;\n if (retUnit.cnv_ != null)\n retUnit.cnvPfx_ *= s;\n else\n retUnit.magnitude_ *= s;\n let mulVal = s.toString();\n retUnit.name_ = this._concatStrs(mulVal, '*', this.name_, '[', ']');\n retUnit.csCode_ = this._concatStrs(mulVal, '.', this.csCode_, '(', ')');\n retUnit.ciCode_ = this._concatStrs(mulVal, '.', this.ciCode_, '(', ')');\n retUnit.printSymbol_ = this._concatStrs(mulVal, '.', this.printSymbol_,\n '(', ')');\n\n return retUnit;\n\n } // end multiplyThis\n\n\n /**\n * Multiplies this unit with another unit. If one of the\n * units is a non-ratio unit the other must be dimensionless or\n * else an exception is thrown.\n *\n * This function does NOT modify this unit\n * @param unit2 the unit to be multiplied with this one\n * @return this unit after it is multiplied\n * @throws an error if one of the units is not on a ratio-scale\n * and the other is not dimensionless.\n */\n multiplyThese(unit2) {\n\n var retUnit = this.clone() ;\n\n if (retUnit.cnv_ != null) {\n if (unit2.cnv_ == null && (!unit2.dim_ || unit2.dim_.isZero()))\n retUnit.cnvPfx_ *= unit2.magnitude_;\n else\n throw (new Error(`Attempt to multiply non-ratio unit ${retUnit.name_} ` +\n 'failed.'));\n } // end if this unit has a conversion function\n\n else if (unit2.cnv_ != null) {\n if (!retUnit.dim_ || retUnit.dim_.isZero()) {\n retUnit.cnvPfx_ = unit2.cnvPfx_ * retUnit.magnitude_;\n retUnit.magnitude_ = unit2.magnitude_;\n retUnit.cnv_ = unit2.cnv_ ;\n }\n else\n throw (new Error(`Attempt to multiply non-ratio unit ${unit2.name_}`));\n } // end if unit2 has a conversion function\n\n // else neither unit has a conversion function\n else {\n retUnit.magnitude_ *= unit2.magnitude_;\n } // end if unit2 does not have a conversion function\n\n // If this.dim_ isn't there, clone the dimension in unit2 - if dimVec_\n // is a dimension in unit2.dim_; else just transfer it to this dimension\n if (!retUnit.dim_ || (retUnit.dim_ && !retUnit.dim_.dimVec_)) {\n if (unit2.dim_)\n retUnit.dim_ = unit2.dim_.clone();\n else\n retUnit.dim_ = unit2.dim_;\n }\n // Else this.dim_ is there. If there is a dimension for unit2,\n // add it to this one.\n else if (unit2.dim_ && unit2.dim_ instanceof Dimension) {\n retUnit.dim_.add(unit2.dim_);\n }\n\n // Add the values of equivalentExp_ and moleExp for the two units\n retUnit.equivalentExp_ += unit2.equivalentExp_;\n retUnit.moleExp_ += unit2.moleExp_;\n\n // Concatenate the unit info (name, code, etc) for all cases\n // where the multiplication was performed (an error wasn't thrown)\n retUnit.name_ = this._concatStrs(retUnit.name_, '*', unit2.name_, '[', ']');\n retUnit.csCode_ = this._concatStrs(retUnit.csCode_, '.', unit2.csCode_,\n '(', ')');\n if (retUnit.ciCode_ && unit2.ciCode_)\n retUnit.ciCode_ = this._concatStrs(retUnit.ciCode_, '.', unit2.ciCode_,\n '(', ')');\n else if (unit2.ciCode_)\n retUnit.ciCode_ = unit2.ciCode_;\n retUnit.resetFieldsForDerivedUnit();\n if (retUnit.printSymbol_ && unit2.printSymbol_)\n retUnit.printSymbol_ = this._concatStrs(retUnit.printSymbol_, '.',\n unit2.printSymbol_, '(', ')');\n else if (unit2.printSymbol_)\n retUnit.printSymbol_ = unit2.printSymbol_;\n\n // A unit that has the arbitrary attribute taints any unit created from it\n // via an arithmetic operation. Taint accordingly\n // if (!retUnit.isMole_)\n // retUnit.isMole_ = unit2.isMole_ ;\n if (!retUnit.isArbitrary_)\n retUnit.isArbitrary_ = unit2.isArbitrary_;\n\n // Likewise for special units\n if (!retUnit.isSpecial_)\n retUnit.isSpecial_ = unit2.isSpecial_;\n\n return retUnit ;\n\n } // end multiplyThese\n\n\n /**\n * Clears fields like isBase_, synonyms_, etc. when a unit has been cloned\n * from a known unit but it being used to construct a derived unit.\n */\n resetFieldsForDerivedUnit() {\n this.guidance_ = '';\n this.synonyms_ = null;\n this.isBase_ = false;\n }\n\n\n /**\n * Divides this unit by another unit. If this unit is not on a ratio\n * scale an exception is raised. Mutating to a ratio scale unit\n * is not possible for a unit, only for a measurement.\n *\n * This unit is NOT modified by this function.\n * @param unit2 the unit by which to divide this one\n * @return this unit after it is divided by unit2\n * @throws an error if either of the units is not on a ratio scale.\n * */\n divide(unit2) {\n\n var retUnit = this.clone();\n\n if (retUnit.cnv_ != null)\n throw (new Error(`Attempt to divide non-ratio unit ${retUnit.name_}`));\n if (unit2.cnv_ != null)\n throw (new Error(`Attempt to divide by non-ratio unit ${unit2.name_}`));\n\n if (retUnit.name_ && unit2.name_)\n retUnit.name_ = this._concatStrs(retUnit.name_, '/', unit2.name_, '[', ']');\n else if (unit2.name_)\n retUnit.name_ = unit2.invertString(unit2.name_);\n\n retUnit.csCode_ = this._concatStrs(retUnit.csCode_, '/', unit2.csCode_,\n '(', ')');\n\n if (retUnit.ciCode_ && unit2.ciCode_)\n retUnit.ciCode_ = this._concatStrs(retUnit.ciCode_, '/', unit2.ciCode_,\n '(', ')');\n else if (unit2.ciCode_)\n retUnit.ciCode_ = unit2.invertString(unit2.ciCode_) ;\n\n retUnit.resetFieldsForDerivedUnit();\n\n retUnit.magnitude_ /= unit2.magnitude_;\n\n if (retUnit.printSymbol_ && unit2.printSymbol_)\n retUnit.printSymbol_ = this._concatStrs(retUnit.printSymbol_, '/',\n unit2.printSymbol_, '(', ')');\n else if (unit2.printSymbol_)\n retUnit.printSymbol_ = unit2.invertString(unit2.printSymbol_);\n\n // Continue if unit2 has a dimension object.\n // If this object has a dimension object, subtract unit2's dim_ object from\n // this one. The sub method will take care of cases where the dimVec_ arrays\n // are missing on one or both dim_ objects.\n if (unit2.dim_) {\n if (retUnit.dim_) {\n if (retUnit.dim_.isNull())\n retUnit.dim_.assignZero();\n retUnit.dim_ = retUnit.dim_.sub(unit2.dim_);\n } // end if this.dim_ exists\n\n // Else if this dim_ object is missing, clone unit2's dim_ object\n // and give the inverted clone to this unit.\n else\n retUnit.dim_ = unit2.dim_.clone().minus();\n } // end if unit2 has a dimension object\n\n // Update the mole exponent count by subtracting the count for unit2 from\n // the count for this unit.\n retUnit.moleExp_ -= unit2.moleExp_ ;\n // Also update the equivalent exponent.\n retUnit.equivalentExp_ -= unit2.equivalentExp_;\n\n // A unit that has the arbitrary attribute taints any unit created from\n // it via an arithmetic operation. Taint accordingly\n // if (!retUnit.isMole_)\n // retUnit.isMole_ = unit2.isMole_ ;\n if (!retUnit.isArbitrary_)\n retUnit.isArbitrary_ = unit2.isArbitrary_;\n\n return retUnit;\n\n } // end divide\n\n\n /**\n * This function is not actually used by the other code, except for some test\n * code, and might not be adequately tested.\n *\n * Invert this unit with respect to multiplication. If this unit is not\n * on a ratio scale an exception is thrown. Mutating to a ratio scale unit\n * is not possible for a unit, only for a measurement (the magnitude and\n * dimension).\n *\n * This unit is modified by this function.\n * @return this unit after being inverted\n * @throws and error if this unit is not on a ratio scale\n */\n invert() {\n var retUnit = this.clone() ;\n if (this.cnv_ != null)\n throw (new Error(`Attempt to invert a non-ratio unit - ${this.name_}`));\n\n retUnit.name_ = this.invertString(this.name_);\n retUnit.magnitude_ = 1/this.magnitude_ ;\n retUnit.dim_.minus();\n\n // Also update equivalentExp_ and moleExp\n retUnit.equivalentExp_ = -this.equivalentExp_;\n retUnit.moleExp_ = -this.moleExp_;\n\n return retUnit;\n\n } // end invert\n\n\n /**\n * Inverts a string, where the string is assumed to be a code or a name\n * of a division operation where the string is the divisor and the dividend\n * is blank.\n *\n * @param the string to be inverted\n * @return the inverted string\n */\n invertString(theString) {\n\n if (theString.length > 0) {\n // replace('<!', '</') is here to make sure closing html tags like </sup> are intact. See LF-2830.\n let stringRep = theString.replace('/', \"!\").replace('.', '/').replace('<!', '</').replace(\"!\", '.');\n switch(stringRep.charAt(0)) {\n case '.' : theString = stringRep.substr(1); break;\n case '/' : theString = stringRep; break;\n default : theString = \"/\" + stringRep;\n }\n }\n return theString;\n\n } // end invertString\n\n\n /**\n * This function handles concatenation of two strings and an operator.\n * It's called to build unit data, e.g., unit name, unit code, etc., from\n * two different units, joined by the specified operator.\n *\n * @param str1 the first string to appear in the result\n * @param operator the operator ('*', '.' or '/') to appear between the strings\n * @param str2 the second string to appear in the result\n * @param startChar the starting character to be used, when needed, to\n * enclose a string\n * @param endChar the ending character to be used, when needed, to enclose\n * a string\n * @returns the built string\n */\n _concatStrs(str1, operator, str2, startChar, endChar) {\n\n return this._buildOneString(str1, startChar, endChar) +\n operator + this._buildOneString(str2, startChar, endChar) ;\n }\n\n\n /**\n * This function handles creation of one string to be included in a\n * concatenated string. Basically it checks to see if the string\n * needs to be enclosed either in parentheses or square brackets.\n *\n * The string is enclosed if it is not a number, is not already enclosed in a pair of\n * parentheses or square brackets, and includes a period, and asterisk,\n * a slash or a blank space.\n *\n * @param str the string\n * @param startChar starting enclosing character\n * @param endChar ending enclosing character\n * @returns the string\n */\n _buildOneString(str, startChar, endChar) {\n let ret = '' ;\n if (intUtils_.isNumericString(str)) {\n ret = str;\n }\n else {\n if (str.charAt(0) === '(' && str.endsWith(')') || str.charAt(0) === '[' && str.endsWith(']')) {\n ret = str;\n }\n else if (/[./* ]/.test(str)) {\n ret = startChar + str + endChar ;\n }\n else {\n ret = str ;\n }\n }\n return ret ;\n }\n\n\n /**\n * This function is not actually used by the other code, except for some test\n * code, and might not be adequately tested.\n *\n * Raises the unit to a power. For example\n * kg.m/s2 raised to the -2 power would be kg-2.m-2/s-4\n *\n * If this unit is not on a ratio scale an error is thrown. Mutating\n * to a ratio scale unit is not possible for a unit, only for a\n * measurement (magnitude and dimension).\n *\n * This is based on the pow method in Gunter Schadow's java version,\n * although it uses javascript capabilities to simplify the processing.\n *\n * This unit is modified by this function\n *\n * @param p the power to with this unit is to be raise\n * @return this unit after it is raised\n * @throws an error if this unit is not on a ratio scale.\n */\n power(p) {\n\n if (this.cnv_ != null)\n throw (new Error(`Attempt to raise a non-ratio unit, ${this.name_}, ` +\n 'to a power.'));\n\n var retUnit = this.clone() ;\n //this.name_ = UnitString.pow(this.name_, p);\n // the above line is replaced with the code below, as the pow method\n // never actually existing in the UnitString class. (Tried to use\n // Schadow java code but this way ended up being a lot easier).\n let uStr = this.csCode_ ;\n let uArray = uStr.match(/([./]|[^./]+)/g) ;\n let arLen = uArray.length;\n\n for (let i = 0; i < arLen; i++) {\n let un = uArray[i] ;\n if (un !== '/' && un !== '.') {\n let nun = parseInt(un);\n if (isInteger(nun))\n uArray[i] = (Math.pow(nun, p).toString());\n else {\n let uLen = un.length ;\n for (let u = uLen - 1; u >= 0; u--) {\n let uChar = parseInt(un[u]);\n if (!isInteger(uChar)) {\n if (un[u] === '-' || un[u] === '+') {\n u--;\n }\n if (u < uLen - 1) {\n let exp = parseInt(un.substr(u));\n exp = Math.pow(exp, p);\n uArray[i] = un.substr(0, u) + exp.toString();\n u = -1;\n }\n else {\n uArray[i] += p.toString();\n u = -1;\n } // end if there are/aren't some numbers at the end\n u = -1;\n } // end if this character is not a number\n } // end searching backwards for start of exponent\n } // end if this element is not a number\n } // end if the current element is not an operator\n } // end do for each element of the units array\n\n // reassemble the updated units array to a string\n retUnit.csCode_ = uArray.join('');\n\n retUnit.magnitude_ = Math.pow(this.magnitude_, p);\n if (retUnit.dim_) {\n retUnit.dim_.mul(p);\n }\n\n // Also update equivalentExp_ and moleExp\n retUnit.equivalentExp_ *= p;\n retUnit.moleExp_ *= p;\n\n return retUnit;\n\n } // end power\n\n\n /*\n * This function tests this unit against the unit passed in to see if the\n * two are mole to mass commensurable. It assumes that one of the units\n * is a mole-based unit and the other is a mass-based unit. It also assumes\n * that the mole-based unit has a single mole unit in the numerator and that\n * the mass-based unit has a single mass unit in the numerator. It does NOT\n * check to validate those assumptions.\n *\n * The check is made by setting the dimension vector element corresponding\n * to the base mass unit (gram) in the mole unit, and then comparing the\n * two dimension vectors. If they match, the units are commensurable.\n * Otherwise they are not.\n *\n * @param unit2 the unit to be compared to this one\n * @returns boolean indicating commensurability\n */\n isMolMassCommensurable(unit2) {\n let tabs = this._getUnitTables();\n let d = tabs.getMassDimensionIndex();\n // Add the moleExp_ values to the mass values in the dimension vectors\n // of each unit, and then compare them.\n const unit1Dim = this.dim_.clone();\n unit1Dim.setElementAt(d, (unit1Dim.getElementAt(d) + this.moleExp_));\n const unit2Dim = unit2.dim_.clone();\n unit2Dim.setElementAt(d, (unit2Dim.getElementAt(d) + unit2.moleExp_));\n return (unit1Dim.equals(unit2Dim));\n }\n\n\n /**\n * This function tests this unit against the unit passed in to see if the\n * two are eq to mass commensurable. It assumes that one of the units\n * is a eq-based unit and the other is a mass-based unit. It also assumes\n * that the eq-based unit has a single eq unit in the numerator and that\n * the mass-based unit has a single mass unit in the numerator. It does NOT\n * check to validate those assumptions.\n *\n * The check is made by setting the dimension vector element corresponding\n * to the base mass unit (gram) in the eq unit, and then comparing the\n * two dimension vectors. If they match, the units are commensurable.\n * Otherwise they are not.\n *\n * @param {Unit} unit2 the unit to be compared to this one\n * @returns {boolean} boolean indicating commensurability\n */\n isEqMassCommensurable(unit2) {\n let tabs = this._getUnitTables();\n let d = tabs.getMassDimensionIndex();\n // Add the equivalentExp_ values to the mass values in the dimension vectors\n // of each unit, and then compare them.\n const unit1Dim = this.dim_.clone();\n unit1Dim.setElementAt(d, (unit1Dim.getElementAt(d) + this.equivalentExp_));\n const unit2Dim = unit2.dim_.clone();\n unit2Dim.setElementAt(d, (unit2Dim.getElementAt(d) + unit2.equivalentExp_));\n return (unit1Dim.equals(unit2Dim));\n }\n\n /**\n * This function tests this unit against the unit passed in to see if the\n * two are eq to mass commensurable-- that the equivalents could be converted\n * to the mass or vice-versa, in a way that makes the units commensurable.\n *\n * The check is made by adding the mole dimension to the equivalent dimension\n * and comparing that result for the two units, along with the units'\n * dimension vectors. If they match, the units are\n * commensurable. Otherwise they are not.\n *\n * @param {Unit} unit2 the unit to be compared to this one\n * @returns {boolean} boolean indicating commensurability\n */\n isEqMolCommensurable(unit2) {\n const unit1Sum = this.equivalentExp_ + this.moleExp_;\n const unit2Sum = unit2.equivalentExp_ + unit2.moleExp_;\n return unit1Sum == unit2Sum && this.dim_.equals(unit2.dim_);\n }\n\n\n /**\n * This function tests this unit against the unit passed in to see if the\n * two are commensurable if eq, mol, and mass units are converted in some\n * direction.\n *\n * The check is made by adding the eq, mol, and mass dimensions\n * and comparing that result for the two units, along with the units'\n * dimension vectors. If they match, the units are\n * commensurable. Otherwise they are not.\n *\n * @param {Unit} unit2 the unit to be compared to this one\n * @returns {boolean} boolean indicating commensurability\n */\n isEqMolMassCommensurable(unit2) {\n const d = this._getUnitTables().getMassDimensionIndex();\n const unit1Dim = this.dim_.clone();\n unit1Dim.setElementAt(d, unit1Dim.getElementAt(d) + this.equivalentExp_ +\n this.moleExp_);\n const unit2Dim = unit2.dim_.clone();\n unit2Dim.setElementAt(d, unit2Dim.getElementAt(d) + unit2.equivalentExp_ +\n unit2.moleExp_);\n return unit1Dim.equals(unit2Dim);\n }\n\n\n /**\n * This returns the UnitTables singleton object. Including the require\n * statement included here causes a circular dependency condition that\n * resulted in the UnitTables object not being defined for the Unit object.\n * sigh. Thanks, Paul, for figuring this out.\n *\n * @private\n */\n _getUnitTables() {\n if (!UnitTables)\n UnitTables = require('./unitTables.js').UnitTables;\n return UnitTables.getInstance();\n }\n\n} // end Unit class\n"],"mappings":";;;;;;AAYA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAoD,SAAAG,yBAAA,eAAAC,OAAA,kCAAAC,KAAA,OAAAD,OAAA,IAAAD,wBAAA,YAAAA,CAAA,WAAAE,KAAA,YAAAA,KAAA;AAAA,SAAAH,wBAAAI,GAAA,QAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAD,KAAA,GAAAF,wBAAA,QAAAE,KAAA,IAAAA,KAAA,CAAAI,GAAA,CAAAH,GAAA,YAAAD,KAAA,CAAAK,GAAA,CAAAJ,GAAA,SAAAK,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAV,GAAA,QAAAO,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAb,GAAA,EAAAU,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAT,GAAA,EAAAU,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAV,GAAA,CAAAU,GAAA,SAAAL,MAAA,CAAAH,OAAA,GAAAF,GAAA,MAAAD,KAAA,IAAAA,KAAA,CAAAgB,GAA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CAAC;IAChB,MAAM8I,QAAQ,GAAGpH,KAAK,CAACpC,IAAI,CAAC8B,KAAK,CAAC,CAAC;IACnC0H,QAAQ,CAACD,YAAY,CAACnD,CAAC,EAAEoD,QAAQ,CAAC9E,YAAY,CAAC0B,CAAC,CAAC,GAAGhE,KAAK,CAACzB,cAAc,GACtEyB,KAAK,CAAC1B,QAAQ,CAAC;IACjB,OAAO4I,QAAQ,CAACjH,MAAM,CAACmH,QAAQ,CAAC;EAClC;;EAGA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE5E,cAAcA,CAAA,EAAG;IACf,IAAI,CAACxF,UAAU,EACbA,UAAU,GAAGxB,OAAO,CAAC,iBAAiB,CAAC,CAACwB,UAAU;IACpD,OAAOA,UAAU,CAAC0K,WAAW,CAAC,CAAC;EACjC;AAEF,CAAC,CAAC;AAAAC,OAAA,CAAAzK,IAAA,GAAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"unit.js","names":["_ucumFunctions","_interopRequireDefault","require","intUtils_","_interopRequireWildcard","_getRequireWildcardCache","WeakMap","cache","obj","__esModule","default","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Ucum","Dimension","UnitTables","isInteger","Unit","constructor","attrs","isBase_","name_","csCode_","ciCode_","property_","magnitude_","undefined","dim_","Array","printSymbol_","class_","isMetric_","variable_","cnv_","cnvPfx_","isSpecial_","isArbitrary_","moleExp_","equivalentExp_","synonyms_","source_","loincProperty_","category_","guidance_","csUnitString_","ciUnitString_","baseFactorStr_","baseFactor_","defError_","assignUnity","assignZero","assignVals","vals","uKey","charAt","length","Error","clone","retUnit","getOwnPropertyNames","forEach","val","assign","unit2","equals","fullEquals","thisAttr","keys","sort","u2Attr","keyLen","match","k","getProperty","propertyName","uProp","convertFrom","num","fromUnit","newNum","isMolMassCommensurable","needMoleWeightMsg_","isNull","fromCnv","fromMag","x","fromFunc","funcs","forName","cnvFrom","toFunc","cnvTo","convertTo","toUnit","convertCoherent","f_from","mutateCoherent","i","max","getMax","elem","getElementAt","tabs","_getUnitTables","uA","getUnitsByDimension","name","convertMolMass","amt","molecularWeight","molPowersToConvert","avoNum","getUnitByCode","moleUnitFactor","Math","pow","convertEqMass","charge","massPowersToConvert","equivalentMass","avogadroNumber","equivalents","moleFactor","adjustedEquivalents","convertEqMolMass","eqPowersToConvert","molAmt","d","getMassDimensionIndex","isEquivalentUnit","isMolarUnit","convertEqMol","mutateRatio","multiplyThis","s","mulVal","toString","_concatStrs","multiplyThese","isZero","dimVec_","add","resetFieldsForDerivedUnit","divide","invertString","sub","minus","invert","theString","stringRep","replace","substr","str1","operator","str2","startChar","endChar","_buildOneString","str","ret","isNumericString","endsWith","test","power","p","uStr","uArray","arLen","un","nun","parseInt","uLen","u","uChar","exp","join","mul","unit1Dim","setElementAt","unit2Dim","isEqMassCommensurable","isEqMolCommensurable","unit1Sum","unit2Sum","isEqMolMassCommensurable","getInstance","exports"],"sources":["../source/unit.js"],"sourcesContent":["\n/**\n * This class represents one unit of measure. It includes\n * functions to cover constructor, accessor, and assignment tasks as\n * well as operators to calculate multiplication, division and raising\n * to a power.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\nvar Ucum = require('./config.js').Ucum;\nvar Dimension = require('./dimension.js').Dimension;\nimport funcs from \"./ucumFunctions.js\";\nvar UnitTables;\n\nvar isInteger = require(\"is-integer\");\nimport * as intUtils_ from \"./ucumInternalUtils.js\";\n\nexport class Unit {\n\n /**\n * Constructor.\n *\n * @param attrs an optional parameter that may be:\n * a string, which is parsed by the unit parser, which creates\n * the unit from the parsed string; or\n * a hash containing all or some values for the attributes of\n * the unit, where the keys are the attribute names, without a\n * trailing underscore, e.g., name instead of name_; or\n * null, in which case an empty hash is created and used to\n * set the values forthe attributes.\n * If a hash (empty or not) is used, attributes for which no value\n * is specified are assigned a default value.\n *\n */\n constructor(attrs = {}) {\n\n // Process the attrs hash passed in, which may be empty.\n // Create and assign values (from the attrs hash or defaults) to all\n // attributes. From Class Declarations in Understanding ECMAScript,\n // https://leanpub.com/understandinges6/read/#leanpub-auto-class-declarations,\n // \"Own properties, properties that occur on the instance rather than the\n // prototype, can only be created inside of a class constructor or method.\n // It's recommended to create all possible own properties inside of the\n // constructor function so there's a single place that's responsible for\n // all of them.\"\n\n /*\n * Flag indicating whether or not this is a base unit\n */\n this.isBase_ = attrs['isBase_'] || false ;\n\n /*\n * The unit name, e.g., meter\n */\n this.name_ = attrs['name_'] || '';\n\n /*\n * The unit's case-sensitive code, e.g., m\n */\n this.csCode_ = attrs['csCode_'] || '';\n\n /*\n * The unit's case-insensitive code, e.g., M\n */\n this.ciCode_ = attrs['ciCode_'] || '';\n\n /*\n * The unit's property, e.g., length\n */\n this.property_ = attrs['property_'] || '';\n\n /*\n * The magnitude of the unit, e.g., 3600/3937 for a yard,\n * where a yard - 3600/3973 * m(eter). The Dimension\n * property specifies the meter - which is the unit on which\n * a yard is based, and this magnitude specifies how to figure\n * this unit based on the base unit.\n */\n this.magnitude_ = attrs['magnitude_'] || 1;\n\n /*\n * The Dimension object of the unit\n */\n if (attrs['dim_'] === undefined || attrs['dim_'] === null) {\n this.dim_ = new Dimension();\n }\n // When the unit data stored in json format is reloaded, the dimension data\n // is recognized as a a hash, not as a Dimension object.\n else if (attrs['dim_']['dimVec_'] !== undefined) {\n this.dim_ = new Dimension(attrs['dim_']['dimVec_']) ;\n }\n else if (attrs['dim_'] instanceof Dimension) {\n this.dim_ = attrs['dim_'];\n }\n else if (attrs['dim_'] instanceof Array || isInteger(attrs['dim_'])) {\n this.dim_ = new Dimension(attrs['dim_']) ;\n }\n else {\n this.dim_ = new Dimension();\n }\n /*\n * The print symbol of the unit, e.g., m\n */\n this.printSymbol_ = attrs['printSymbol_'] || null;\n\n /*\n * The class of the unit, where given, e.g., dimless\n */\n this.class_ = attrs['class_'] || null;\n\n /*\n * A flag indicating whether or not the unit is metric\n */\n this.isMetric_ = attrs['isMetric_'] || false;\n\n /*\n * The \"variable\" - which I think is used only for base units\n * The symbol for the variable as used in equations, e.g., s for distance\n */\n this.variable_ = attrs['variable_'] || null ; // comes from 'dim' in XML\n\n /*\n * The conversion function\n */\n this.cnv_ = attrs['cnv_'] || null;\n\n /*\n * The conversion prefix\n */\n this.cnvPfx_ = attrs['cnvPfx_'] || 1;\n\n /*\n * Flag indicating whether or not this is a \"special\" unit, i.e., is\n * constructed using a function specific to the measurement, e.g.,\n * fahrenheit and celsius\n */\n this.isSpecial_ = attrs['isSpecial_'] || false ;\n\n /*\n * Flag indicating whether or not this is an arbitrary unit\n */\n this.isArbitrary_ = attrs['isArbitrary_'] || false;\n\n /*\n * Integer indicating what level of exponent applies to a mole-based portion\n * of the unit. So, for the unit \"mol\", this will be 1. For \"mol2\" this\n * will be 2. For \"1/mol\" this will be -1. Any unit that does not include\n * a mole will have a 0 in this field. This is used to determine\n * commensurability for mole<->mass conversions.\n */\n this.moleExp_ = attrs['moleExp_'] || 0;\n\n /**\n * Flag indicating whether or not this is a equivalent mole unit\n */\n this.equivalentExp_ = attrs['equivalentExp_'] || 0;\n\n /*\n * Added when added LOINC list of units\n * synonyms are used by the autocompleter to enhance lookup capabilities\n * while source says where the unit first shows up. Current sources are\n * UCUM - which are units from the unitsofmeasure.org list and LOINC -\n * which are units from the LOINC data.\n */\n this.synonyms_ = attrs['synonyms_'] || null ;\n this.source_ = attrs['source_'] || null ;\n this.loincProperty_ = attrs['loincProperty_'] || null;\n this.category_ = attrs['category_'] || null;\n this.guidance_ = attrs['guidance_'] || null;\n\n /*\n * Used to compute dimension; storing for now until I complete\n * unit definition parsing\n */\n /*\n * Case sensitive (cs) and case insensitive (ci) base unit strings,\n * includes exponent and prefix if applicable - specified in\n * <value Unit=x UNIT=X value=\"nnn\">nnn</value> -- the unit part --\n * in the ucum-essence.xml file, and may be specified by a user\n * when requesting conversion or validation of a unit string. The\n * magnitude (base factor) is used with this to determine the new unit.\n * For example, a Newton (unit code N) is created from the string\n * kg.m/s2, and the value of 1 (base factor defined below). An hour\n * (unit code h) is created from the unit min (minute) with a value\n * of 60.\n */\n this.csUnitString_ = attrs['csUnitString_'] || null ;\n this.ciUnitString_ = attrs['ciUnitString_'] || null ;\n\n /*\n * String and numeric versions of factor applied to unit specified in\n * <value Unit=x UNIT=X value=\"nnn\">nnn</value> -- the value part\n */\n this.baseFactorStr_ = attrs['baseFactorStr_'] || null;\n this.baseFactor_ = attrs['baseFactor_'] || null;\n\n /*\n * Flag used to indicate units where the definition process failed\n * when parsing units from the official units definitions file\n * (currently using the ucum-essence.xml file). We keep these\n * so that we can use them to at least validate them as valid\n * units, but we don't try to convert them. This is temporary\n * and only to account for instances where the code does not\n * take into account various special cases in the xml file.\n *\n * This is NOT used when trying to validate a unit string\n * submitted during a conversion or validation attempt.\n */\n this.defError_ = attrs['defError_'] || false ;\n\n\n } // end constructor\n\n\n /**\n * Assign the unity (= dimensionless unit 1) to this unit.\n *\n * @return this unit\n */\n assignUnity() {\n this.name_ = \"\" ;\n this.magnitude_ = 1 ;\n if (!this.dim_)\n this.dim_ = new Dimension();\n this.dim_.assignZero() ;\n this.cnv_ = null ;\n this.cnvPfx_ = 1 ;\n return this;\n\n } // end assignUnity\n\n\n /**\n * This assigns one or more values, as provided in the hash passed in,\n * to this unit.\n *\n * @param vals hash of values to be assigned to the attributes\n * specified by the key(s), which should be the attribute\n * name without the trailing underscore, e.g., name instead\n * of name_.\n * @return nothing\n */\n assignVals(vals) {\n for (let key in vals) {\n let uKey = !(key.charAt(key.length - 1)) === '_' ? key + '_' : key ;\n if (this.hasOwnProperty(uKey))\n this[uKey] = vals[key];\n else\n throw(new Error(`Parameter error; ${key} is not a property of a Unit`));\n }\n } // end assignVals\n\n\n /**\n * This creates a clone of this unit.\n *\n * @return the clone\n */\n clone() {\n let retUnit = new Unit() ;\n Object.getOwnPropertyNames(this).forEach(val => {\n if (val === 'dim_') {\n if (this['dim_'])\n retUnit['dim_'] = this['dim_'].clone();\n else\n retUnit['dim_'] = null;\n }\n else\n retUnit[val] = this[val];\n });\n return retUnit ;\n\n } // end clone\n\n\n /**\n * This assigns all properties of a unit passed to it to this unit.\n *\n * @param unit2 the unit whose properties are to be assigned to this one.\n * @return nothing; this unit is updated\n */\n assign(unit2) {\n Object.getOwnPropertyNames(unit2).forEach(val => {\n if (val === 'dim_') {\n if (unit2['dim_'])\n this['dim_'] = unit2['dim_'].clone();\n else\n this['dim_'] = null;\n }\n else {\n this[val] = unit2[val];\n }\n });\n } // end assign\n\n\n /**\n * This determines whether or not object properties of the unit\n * passed in are equal to the corresponding properties in this unit.\n * The following properties are the only ones checked:\n * magnitude_, dim_, cnv_ and cnvPfx_\n *\n * @param unit2 the unit whose properties are to be checked.\n * @return boolean indicating whether or not they match\n */\n equals(unit2) {\n\n return (this.magnitude_ === unit2.magnitude_ &&\n this.cnv_ === unit2.cnv_ &&\n this.cnvPfx_ === unit2.cnvPfx_ &&\n ((this.dim_ === null && unit2.dim_ === null) ||\n this.dim_.equals(unit2.dim_)));\n\n } // end equals\n\n\n /**\n * This method compares every attribute of two objects to determine\n * if they all match.\n *\n * @param unit2 the unit that is to be compared to this unit\n * @return boolean indicating whether or not every attribute matches\n */\n fullEquals(unit2) {\n\n let thisAttr = Object.keys(this).sort();\n let u2Attr = Object.keys(unit2).sort();\n\n let keyLen = thisAttr.length ;\n let match = (keyLen === u2Attr.length);\n\n // check each attribute. Dimension objects have to checked using\n // the equals function of the Dimension class.\n for (let k = 0; k < keyLen && match; k++) {\n if (thisAttr[k] === u2Attr[k]) {\n if (thisAttr[k] === 'dim_')\n match = this.dim_.equals(unit2.dim_);\n else\n match = this[thisAttr[k]] === unit2[thisAttr[k]];\n }\n else\n match = false ;\n } // end do for each key and attribute\n return match ;\n }// end of fullEquals\n\n\n /**\n * This returns the value of the property named by the parameter\n * passed in.\n *\n * @param propertyName name of the property to be returned, with\n * or without the trailing underscore.\n * @return the requested property, if found for this unit\n * @throws an error if the property is not found for this unit\n */\n getProperty(propertyName) {\n let uProp = propertyName.charAt(propertyName.length - 1) === '_' ? propertyName :\n propertyName + '_' ;\n return this[uProp] ;\n\n } // end getProperty\n\n\n /**\n * Takes a measurement consisting of a number of units and a unit and returns\n * the equivalent number of this unit. So, 15 mL would translate\n * to 1 tablespoon if this object is a tablespoon.\n *\n * Note that the number returned may not be what is normally expected.\n * For example, converting 10 Celsius units to Fahrenheit would \"normally\"\n * return a value of 50. But in this case you'll get back something like\n * 49.99999999999994.\n *\n * If either unit is an arbitrary unit an exception is raised.\n *\n * @param num the magnitude for the unit to be translated (e.g. 15 for 15 mL)\n * @param fromUnit the unit to be translated to one of this type (e.g. a mL unit)\n *\n * @return the number of converted units (e.g. 1 for 1 tablespoon)\n * @throws an error if the dimension of the fromUnit differs from this unit's\n * dimension\n */\n convertFrom(num, fromUnit) {\n let newNum = 0.0 ;\n\n if (this.isArbitrary_)\n throw (new Error(`Attempt to convert to arbitrary unit \"${this.csCode_}\"`));\n if (fromUnit.isArbitrary_)\n throw (new Error(`Attempt to convert arbitrary unit \"${fromUnit.csCode_}\"`));\n\n // reject request if both units have dimensions that are not equal\n if (fromUnit.dim_ && this.dim_ && !(fromUnit.dim_.equals(this.dim_))) {\n // check first to see if a mole<->mass conversion is appropriate\n if (this.isMolMassCommensurable(fromUnit)) {\n throw(new Error(Ucum.needMoleWeightMsg_));\n }\n else {\n throw(new Error(`Sorry. ${fromUnit.csCode_} cannot be converted ` +\n `to ${this.csCode_}.`));\n }\n }\n // reject request if there is a \"from\" dimension but no \"to\" dimension\n if (fromUnit.dim_ && (!this.dim_ || this.dim_.isNull())) {\n throw(new Error(`Sorry. ${fromUnit.csCode_} cannot be converted ` +\n `to ${this.csCode_}.`));\n }\n\n // reject request if there is a \"to\" dimension but no \"from\" dimension\n if (this.dim_ && (!fromUnit.dim_ || fromUnit.dim_.isNull())) {\n throw(new Error(`Sorry. ${fromUnit.csCode_} cannot be converted ` +\n `to ${this.csCode_}.`));\n }\n\n let fromCnv = fromUnit.cnv_ ;\n let fromMag = fromUnit.magnitude_ ;\n\n let x;\n if (fromCnv != null) {\n // turn num * fromUnit.magnitude into its ratio scale equivalent,\n // e.g., convert Celsius to Kelvin\n let fromFunc = funcs.forName(fromCnv);\n x = fromFunc.cnvFrom(num * fromUnit.cnvPfx_) * fromMag;\n //x = fromFunc.cnvFrom(num * fromMag) * fromUnit.cnvPfx_;\n }\n else {\n x = num * fromMag;\n }\n\n if (this.cnv_ != null) {\n // turn mag * origUnit on ratio scale into a non-ratio unit,\n // e.g. convert Kelvin to Fahrenheit\n let toFunc = funcs.forName(this.cnv_);\n newNum = toFunc.cnvTo(x / this.magnitude_) / this.cnvPfx_;\n }\n else {\n newNum = x / this.magnitude_;\n }\n\n return newNum;\n\n } // end convertFrom\n\n\n /**\n * Takes a number and a target unit and returns the number for a measurement\n * of this unit that corresponds to the number of the target unit passed in.\n * So, 1 tablespoon (where this unit represents a tablespoon) would translate\n * to 15 mL.\n *\n * See the note on convertFrom about return values.\n *\n * @param mag the magnitude for this unit (e.g. 1 for 1 tablespoon)\n * @param toUnit the unit to which this unit is to be translated\n * (e.g. an mL unit)\n *\n * @return the converted number value (e.g. 15 mL)\n * @throws an error if the dimension of the toUnit differs from this unit's\n * dimension\n */\n convertTo(num, toUnit) {\n\n return toUnit.convertFrom(num, this) ;\n\n } // end convertTo\n\n\n /**\n * Takes a given number of this unit returns the number of this unit\n * if it is converted into a coherent unit. Does not change this unit.\n *\n * If this is a coherent unit already, just gives back the number\n * passed in.\n *\n * @param num the number for the coherent version of this unit\n * @return the number for the coherent version of this unit\n */\n convertCoherent(num) {\n\n // convert mag' * u' into canonical number * u on ratio scale\n if(this.cnv_ !== null)\n num = this.cnv_.f_from(num / this.cnvPfx_) * this.magnitude_;\n\n return num;\n\n } // end convertCoherent\n\n\n /**\n * Mutates this unit into a coherent unit and converts a given number of\n * units to the appropriate value for this unit as a coherent unit\n *\n * @param num the number for this unit before conversion\n * @return the number of this unit after conversion\n * @throws an error if the dimensions differ\n */\n mutateCoherent(num) {\n\n // convert mu' * u' into canonical mu * u on ratio scale\n num = this.convertCoherent(num) ;\n\n // mutate to coherent unit\n this.magnitude_ = 1;\n this.cnv_ = null;\n this.cnvPfx_ = 1;\n this.name_ = \"\";\n\n // build a name as a term of coherent base units\n // This is probably ALL WRONG and a HORRIBLE MISTAKE\n // but until we figure out what the heck the name being\n // built here really is, it will have to stay.\n for (let i = 0, max = Dimension.getMax(); i < max; i++) {\n let elem = this.dim_.getElementAt(i);\n let tabs = this._getUnitTables();\n let uA = tabs.getUnitsByDimension(new Dimension(i));\n if(uA == null)\n throw(new Error(`Can't find base unit for dimension ${i}`));\n this.name_ = uA.name + elem;\n }\n return num;\n\n } // end mutateCoherent\n\n\n /**\n * This function converts between mol and mass (in either direction)\n * using the molecular weight of the substance. It assumes that the\n * isMolMassCommensurable\" function has been called to check that the units are\n * commensurable.\n *\n * @param amt the quantity of this unit to be converted\n * @param toUnit the target/to unit for which the converted # is wanted\n * @param molecularWeight the molecular weight of the substance for which the\n * conversion is being made\n * @return the equivalent amount in toUnit\n */\n convertMolMass(amt, toUnit, molecularWeight) {\n // In the calculations below we are treating \"molecularWeight\" (measured in\n // a.m.u) as the molar weight (measured in g/mol). The values are the same,\n // though the units differ.\n\n // Determine the number of powers of mol we have to convert to mass.\n // Typically this will be just 1, or -1, but not necessarily. If it is a\n // negative number, then we are really converting mass to moles.\n const molPowersToConvert = this.moleExp_ - toUnit.moleExp_;\n // A simple mole unit has a magnitude of avogadro's number. Get that\n // number now (since not everyone agrees on what it is, and what is\n // being used in this system might change).\n let tabs = this._getUnitTables();\n let avoNum = tabs.getUnitByCode('mol').magnitude_ ;\n // For each molPowersToConvert, we need to multiply the mol unit by the\n // molar weight (g/mol) and divide by avoNum (1/mol) to get a weight per\n // molecule. (Note that the magnitude_ of each unit will contain factors of\n // avoNum, of which we are thus getting rid of some).\n let moleUnitFactor = Math.pow(molecularWeight/avoNum, molPowersToConvert);\n // The new value is proportional to this.magnitude_, amt, and\n // moleUnitFactor, and inversely proportional to toUnit_.magnitude.\n return this.magnitude_/toUnit.magnitude_ * moleUnitFactor * amt;\n } // end convertMolMass\n\n\n /**\n * This function converts between equivalants and mass (in either direction)\n * using the charge of the substance. It assumes that the\n * isEqMassCommensurable\" function has been called to check that the units are\n * commensurable.\n *\n * @param {number} amt - The amount of this unit to be converted.\n * @param {object} toUnit - The target/to unit for which the converted number is wanted.\n * @param {number} molecularWeight - The molecular weight of the substance for which the conversion is being made.\n * @param {number} charge - The absolute value of the charge of the substance for which the conversion is being made.\n * @returns {number} - The amount in the specified toUnit.\n */\n convertEqMass(amt, toUnit, molecularWeight, charge) {\n // Determine the number of powers of mass we have to convert to equivalents.\n // Typically this will be just 1, or -1, but not necessarily. If it is a\n // negative number, then we are converting in the opposite direciton.\n // Because the units are presumed commensurable, we can use the\n // equivalentExp_ instead of the mass dimension.\n const massPowersToConvert = toUnit.equivalentExp_ - this.equivalentExp_ ;\n // Calculate equivalent mass by dividing molecular weight by charge\n let equivalentMass = molecularWeight / charge;\n // Get Avogadro's number from the unit tables\n let avogadroNumber = this._getUnitTables().getUnitByCode('mol').magnitude_ ;\n // Calculate equivalents by dividing mass by equivalent mass, for each\n // power to be converted.\n let equivalents = this.magnitude_ * amt / Math.pow(equivalentMass, massPowersToConvert);\n // Calculate mole factor by dividing the magnitude of the equivalent unit by\n // Avogadro's number. toUnit may have a prefix (e.g. meq) and we need to adjust for that, for\n // each massPowersToConvert.\n let moleFactor = toUnit.magnitude_ / Math.pow(avogadroNumber, massPowersToConvert);\n // Adjust equivalents by dividing by the mole factor\n let adjustedEquivalents = equivalents / moleFactor;\n // Return the adjusted equivalents\n return adjustedEquivalents;\n } // end convertMassToEq\n\n\n /**\n * Converts a unit with eq/mol/mass to another unit with eq/mol/mass. It\n * assumes the units an commensurable, which can be checked via\n * isEqMolMassCommensurable. It also assumes that the powers of eq/mol/mass\n * are different between the two units; otherwise it would be more efficient\n * to call one of the other convert... functions.\n *\n * @param {number} amt - The amount of this unit to be converted.\n * @param {object} toUnit - The target/to unit for which the converted number is wanted.\n * @param {number} molecularWeight - The molecular weight of the substance for which the conversion is being made.\n * @param {number} charge - The absolute value of the charge of the substance for which the conversion is being made.\n * @returns {number} - The equivalent amount in the specified equivalent unit.\n */\n convertEqMolMass(amt, toUnit, molecularWeight, charge) {\n // Handle the equivalent differences. It important for the following\n // calculations (for consistency) that we consider the difference in\n // equivalent powers and not mol powers, so we are not calling\n // convertEqToMol, in case its implementation changes.\n // See convertEqToMol for details. One difference is that we do not scale\n // by magnitude_ until the end.\n const eqPowersToConvert = this.equivalentExp_ - toUnit.equivalentExp_;\n const molAmt = amt / Math.pow(charge, eqPowersToConvert);\n // Now for the mol/mass converstion part, we consider only the mass power\n // differences, and not the mol power differences (which were partially\n // handled in the eq/mol step above).\n // Again, see convertMolToMass for details on the calculations.\n const tabs = this._getUnitTables();\n const d = tabs.getMassDimensionIndex();\n const massPowersToConvert = this.dim_.getElementAt(d) - toUnit.dim_.getElementAt(d);\n const molPowersToConvert = -massPowersToConvert; // so the formulas follow convertMolToMass\n const avoNum = tabs.getUnitByCode('mol').magnitude_ ;\n let moleUnitFactor = Math.pow(molecularWeight/avoNum, molPowersToConvert);\n return this.magnitude_/toUnit.magnitude_ * moleUnitFactor * molAmt;\n }\n\n\n /**\n * Checks if the given unit is an equivalent unit.\n *\n * Note: equivalent units are also be molar units, so a unit can return true for\n * both isEquivalentUnit and isMolarUnit.\n *\n * @returns {boolean} - Returns true if the unit is an equivalent unit, false otherwise.\n */\n isEquivalentUnit() {\n return this.equivalentExp_ !== 0;\n } // end isEquivalentUnit\n\n /**\n * Checks if the given unit is a molar unit.\n *\n * @returns {boolean} - Returns true if the unit is a molar unit, false otherwise.\n */\n isMolarUnit() {\n return this.moleExp_ !== 0;\n } // end isMolarUnit\n\n\n /**\n * This function converts between equivalants and moles (in either direction)\n * using the charge of the substance. It assumes that the\n * isEqMolCommensurable\" function has been called to check that the units are\n * commensurable.\n\n * As with the other \"convert\" functions, it assumes the appropriate\n * \"is...Commensurable\" function has been called.\n *\n * @param {number} amt - The amount of this unit for which the conversion is being made.\n * @param {object} toUnit - The target unit for which the converted number is wanted.\n * @param {number} charge - The absolute value of the charge of the substance for which the conversion is being made.\n * @return {number} - The amount in molToUnit.\n */\n convertEqMol(amt, toUnit, charge) {\n // Determine the number of powers of eq we have to convert to mol.\n // Typically this will be just 1, or -1, but not necessarily. If it is a\n // negative number, then we are really converting mol to eq.\n const eqPowersToConvert = this.equivalentExp_ - toUnit.equivalentExp_;\n\n // A simple mole unit has a magnitude of avogadro's number.\n // So does 'eq' (equivalent) because in ucum it is defined as 1 mol, though\n // that does not account for the charge. Therefore, we don't need to\n // account for that factor in this conversion.\n\n // The conversion from equivalents to moles is based on the principle that\n // one equivalent is equal to 1/charge moles (per eqPowersToConvert).\n // The relative magnitude is accounted for via the current unit's magnitude\n // (this.magnitude_) and the target unit's magnitude (molToUnit.magnitude_)\n // For each eqPowersToConvert, we need to divide by the charge.\n return amt * (this.magnitude_ / toUnit.magnitude_) / Math.pow(charge, eqPowersToConvert);\n } // end convertEqMol\n\n\n /**\n * Mutates this unit into a unit on a ratio scale and converts a specified\n * number of units to an appropriate value for this converted unit\n *\n * @param num the number of this unit before it's converted\n * @return the magnitude of this unit after it's converted\n * @throw an error if the dimensions differ\n */\n mutateRatio(num) {\n if (this.cnv_ == null)\n return this.mutateCoherent(num);\n else\n return num;\n\n } // end mutateRatio\n\n\n /**\n * Multiplies this unit with a scalar. Special meaning for\n * special units so that (0.1*B) is 1 dB.\n *\n * This function DOES NOT modify this unit.\n *\n * @param s the value by which this unit is to be multiplied\n * @return a copy this unit multiplied by s\n * */\n multiplyThis(s) {\n\n let retUnit = this.clone() ;\n if (retUnit.cnv_ != null)\n retUnit.cnvPfx_ *= s;\n else\n retUnit.magnitude_ *= s;\n let mulVal = s.toString();\n retUnit.name_ = this._concatStrs(mulVal, '*', this.name_, '[', ']');\n retUnit.csCode_ = this._concatStrs(mulVal, '.', this.csCode_, '(', ')');\n retUnit.ciCode_ = this._concatStrs(mulVal, '.', this.ciCode_, '(', ')');\n retUnit.printSymbol_ = this._concatStrs(mulVal, '.', this.printSymbol_,\n '(', ')');\n\n return retUnit;\n\n } // end multiplyThis\n\n\n /**\n * Multiplies this unit with another unit. If one of the\n * units is a non-ratio unit the other must be dimensionless or\n * else an exception is thrown.\n *\n * This function does NOT modify this unit\n * @param unit2 the unit to be multiplied with this one\n * @return this unit after it is multiplied\n * @throws an error if one of the units is not on a ratio-scale\n * and the other is not dimensionless.\n */\n multiplyThese(unit2) {\n\n var retUnit = this.clone() ;\n\n if (retUnit.cnv_ != null) {\n if (unit2.cnv_ == null && (!unit2.dim_ || unit2.dim_.isZero()))\n retUnit.cnvPfx_ *= unit2.magnitude_;\n else\n throw (new Error(`Attempt to multiply non-ratio unit ${retUnit.name_} ` +\n 'failed.'));\n } // end if this unit has a conversion function\n\n else if (unit2.cnv_ != null) {\n if (!retUnit.dim_ || retUnit.dim_.isZero()) {\n retUnit.cnvPfx_ = unit2.cnvPfx_ * retUnit.magnitude_;\n retUnit.magnitude_ = unit2.magnitude_;\n retUnit.cnv_ = unit2.cnv_ ;\n }\n else\n throw (new Error(`Attempt to multiply non-ratio unit ${unit2.name_}`));\n } // end if unit2 has a conversion function\n\n // else neither unit has a conversion function\n else {\n retUnit.magnitude_ *= unit2.magnitude_;\n } // end if unit2 does not have a conversion function\n\n // If this.dim_ isn't there, clone the dimension in unit2 - if dimVec_\n // is a dimension in unit2.dim_; else just transfer it to this dimension\n if (!retUnit.dim_ || (retUnit.dim_ && !retUnit.dim_.dimVec_)) {\n if (unit2.dim_)\n retUnit.dim_ = unit2.dim_.clone();\n else\n retUnit.dim_ = unit2.dim_;\n }\n // Else this.dim_ is there. If there is a dimension for unit2,\n // add it to this one.\n else if (unit2.dim_ && unit2.dim_ instanceof Dimension) {\n retUnit.dim_.add(unit2.dim_);\n }\n\n // Add the values of equivalentExp_ and moleExp for the two units\n retUnit.equivalentExp_ += unit2.equivalentExp_;\n retUnit.moleExp_ += unit2.moleExp_;\n\n // Concatenate the unit info (name, code, etc) for all cases\n // where the multiplication was performed (an error wasn't thrown)\n retUnit.name_ = this._concatStrs(retUnit.name_, '*', unit2.name_, '[', ']');\n retUnit.csCode_ = this._concatStrs(retUnit.csCode_, '.', unit2.csCode_,\n '(', ')');\n if (retUnit.ciCode_ && unit2.ciCode_)\n retUnit.ciCode_ = this._concatStrs(retUnit.ciCode_, '.', unit2.ciCode_,\n '(', ')');\n else if (unit2.ciCode_)\n retUnit.ciCode_ = unit2.ciCode_;\n retUnit.resetFieldsForDerivedUnit();\n if (retUnit.printSymbol_ && unit2.printSymbol_)\n retUnit.printSymbol_ = this._concatStrs(retUnit.printSymbol_, '.',\n unit2.printSymbol_, '(', ')');\n else if (unit2.printSymbol_)\n retUnit.printSymbol_ = unit2.printSymbol_;\n\n // A unit that has the arbitrary attribute taints any unit created from it\n // via an arithmetic operation. Taint accordingly\n // if (!retUnit.isMole_)\n // retUnit.isMole_ = unit2.isMole_ ;\n if (!retUnit.isArbitrary_)\n retUnit.isArbitrary_ = unit2.isArbitrary_;\n\n // Likewise for special units\n if (!retUnit.isSpecial_)\n retUnit.isSpecial_ = unit2.isSpecial_;\n\n return retUnit ;\n\n } // end multiplyThese\n\n\n /**\n * Clears fields like isBase_, synonyms_, etc. when a unit has been cloned\n * from a known unit but it being used to construct a derived unit.\n */\n resetFieldsForDerivedUnit() {\n this.guidance_ = '';\n this.synonyms_ = null;\n this.isBase_ = false;\n }\n\n\n /**\n * Divides this unit by another unit. If this unit is not on a ratio\n * scale an exception is raised. Mutating to a ratio scale unit\n * is not possible for a unit, only for a measurement.\n *\n * This unit is NOT modified by this function.\n * @param unit2 the unit by which to divide this one\n * @return this unit after it is divided by unit2\n * @throws an error if either of the units is not on a ratio scale.\n * */\n divide(unit2) {\n\n var retUnit = this.clone();\n\n if (retUnit.cnv_ != null)\n throw (new Error(`Attempt to divide non-ratio unit ${retUnit.name_}`));\n if (unit2.cnv_ != null)\n throw (new Error(`Attempt to divide by non-ratio unit ${unit2.name_}`));\n\n if (retUnit.name_ && unit2.name_)\n retUnit.name_ = this._concatStrs(retUnit.name_, '/', unit2.name_, '[', ']');\n else if (unit2.name_)\n retUnit.name_ = unit2.invertString(unit2.name_);\n\n retUnit.csCode_ = this._concatStrs(retUnit.csCode_, '/', unit2.csCode_,\n '(', ')');\n\n if (retUnit.ciCode_ && unit2.ciCode_)\n retUnit.ciCode_ = this._concatStrs(retUnit.ciCode_, '/', unit2.ciCode_,\n '(', ')');\n else if (unit2.ciCode_)\n retUnit.ciCode_ = unit2.invertString(unit2.ciCode_) ;\n\n retUnit.resetFieldsForDerivedUnit();\n\n retUnit.magnitude_ /= unit2.magnitude_;\n\n if (retUnit.printSymbol_ && unit2.printSymbol_)\n retUnit.printSymbol_ = this._concatStrs(retUnit.printSymbol_, '/',\n unit2.printSymbol_, '(', ')');\n else if (unit2.printSymbol_)\n retUnit.printSymbol_ = unit2.invertString(unit2.printSymbol_);\n\n // Continue if unit2 has a dimension object.\n // If this object has a dimension object, subtract unit2's dim_ object from\n // this one. The sub method will take care of cases where the dimVec_ arrays\n // are missing on one or both dim_ objects.\n if (unit2.dim_) {\n if (retUnit.dim_) {\n if (retUnit.dim_.isNull())\n retUnit.dim_.assignZero();\n retUnit.dim_ = retUnit.dim_.sub(unit2.dim_);\n } // end if this.dim_ exists\n\n // Else if this dim_ object is missing, clone unit2's dim_ object\n // and give the inverted clone to this unit.\n else\n retUnit.dim_ = unit2.dim_.clone().minus();\n } // end if unit2 has a dimension object\n\n // Update the mole exponent count by subtracting the count for unit2 from\n // the count for this unit.\n retUnit.moleExp_ -= unit2.moleExp_ ;\n // Also update the equivalent exponent.\n retUnit.equivalentExp_ -= unit2.equivalentExp_;\n\n // A unit that has the arbitrary attribute taints any unit created from\n // it via an arithmetic operation. Taint accordingly\n // if (!retUnit.isMole_)\n // retUnit.isMole_ = unit2.isMole_ ;\n if (!retUnit.isArbitrary_)\n retUnit.isArbitrary_ = unit2.isArbitrary_;\n\n return retUnit;\n\n } // end divide\n\n\n /**\n * This function is not actually used by the other code, except for some test\n * code, and might not be adequately tested.\n *\n * Invert this unit with respect to multiplication. If this unit is not\n * on a ratio scale an exception is thrown. Mutating to a ratio scale unit\n * is not possible for a unit, only for a measurement (the magnitude and\n * dimension).\n *\n * This unit is modified by this function.\n * @return this unit after being inverted\n * @throws and error if this unit is not on a ratio scale\n */\n invert() {\n var retUnit = this.clone() ;\n if (this.cnv_ != null)\n throw (new Error(`Attempt to invert a non-ratio unit - ${this.name_}`));\n\n retUnit.name_ = this.invertString(this.name_);\n retUnit.magnitude_ = 1/this.magnitude_ ;\n retUnit.dim_.minus();\n\n // Also update equivalentExp_ and moleExp\n retUnit.equivalentExp_ = -this.equivalentExp_;\n retUnit.moleExp_ = -this.moleExp_;\n\n return retUnit;\n\n } // end invert\n\n\n /**\n * Inverts a string, where the string is assumed to be a code or a name\n * of a division operation where the string is the divisor and the dividend\n * is blank.\n *\n * @param the string to be inverted\n * @return the inverted string\n */\n invertString(theString) {\n\n if (theString.length > 0) {\n // replace('<!', '</') is here to make sure closing html tags like </sup> are intact. See LF-2830.\n let stringRep = theString.replace('/', \"!\").replace('.', '/').replace('<!', '</').replace(\"!\", '.');\n switch(stringRep.charAt(0)) {\n case '.' : theString = stringRep.substr(1); break;\n case '/' : theString = stringRep; break;\n default : theString = \"/\" + stringRep;\n }\n }\n return theString;\n\n } // end invertString\n\n\n /**\n * This function handles concatenation of two strings and an operator.\n * It's called to build unit data, e.g., unit name, unit code, etc., from\n * two different units, joined by the specified operator.\n *\n * @param str1 the first string to appear in the result\n * @param operator the operator ('*', '.' or '/') to appear between the strings\n * @param str2 the second string to appear in the result\n * @param startChar the starting character to be used, when needed, to\n * enclose a string\n * @param endChar the ending character to be used, when needed, to enclose\n * a string\n * @returns the built string\n */\n _concatStrs(str1, operator, str2, startChar, endChar) {\n\n return this._buildOneString(str1, startChar, endChar) +\n operator + this._buildOneString(str2, startChar, endChar) ;\n }\n\n\n /**\n * This function handles creation of one string to be included in a\n * concatenated string. Basically it checks to see if the string\n * needs to be enclosed either in parentheses or square brackets.\n *\n * The string is enclosed if it is not a number, is not already enclosed in a pair of\n * parentheses or square brackets, and includes a period, and asterisk,\n * a slash or a blank space.\n *\n * @param str the string\n * @param startChar starting enclosing character\n * @param endChar ending enclosing character\n * @returns the string\n */\n _buildOneString(str, startChar, endChar) {\n let ret = '' ;\n if (intUtils_.isNumericString(str)) {\n ret = str;\n }\n else {\n if (str.charAt(0) === '(' && str.endsWith(')') || str.charAt(0) === '[' && str.endsWith(']')) {\n ret = str;\n }\n else if (/[./* ]/.test(str)) {\n ret = startChar + str + endChar ;\n }\n else {\n ret = str ;\n }\n }\n return ret ;\n }\n\n\n /**\n * This function is not actually used by the other code, except for some test\n * code, and might not be adequately tested.\n *\n * Raises the unit to a power. For example\n * kg.m/s2 raised to the -2 power would be kg-2.m-2/s-4\n *\n * If this unit is not on a ratio scale an error is thrown. Mutating\n * to a ratio scale unit is not possible for a unit, only for a\n * measurement (magnitude and dimension).\n *\n * This is based on the pow method in Gunter Schadow's java version,\n * although it uses javascript capabilities to simplify the processing.\n *\n * This unit is modified by this function\n *\n * @param p the power to with this unit is to be raise\n * @return this unit after it is raised\n * @throws an error if this unit is not on a ratio scale.\n */\n power(p) {\n\n if (this.cnv_ != null)\n throw (new Error(`Attempt to raise a non-ratio unit, ${this.name_}, ` +\n 'to a power.'));\n\n var retUnit = this.clone() ;\n //this.name_ = UnitString.pow(this.name_, p);\n // the above line is replaced with the code below, as the pow method\n // never actually existing in the UnitString class. (Tried to use\n // Schadow java code but this way ended up being a lot easier).\n let uStr = this.csCode_ ;\n let uArray = uStr.match(/([./]|[^./]+)/g) ;\n let arLen = uArray.length;\n\n for (let i = 0; i < arLen; i++) {\n let un = uArray[i] ;\n if (un !== '/' && un !== '.') {\n let nun = parseInt(un);\n if (isInteger(nun))\n uArray[i] = (Math.pow(nun, p).toString());\n else {\n let uLen = un.length ;\n for (let u = uLen - 1; u >= 0; u--) {\n let uChar = parseInt(un[u]);\n if (!isInteger(uChar)) {\n if (un[u] === '-' || un[u] === '+') {\n u--;\n }\n if (u < uLen - 1) {\n let exp = parseInt(un.substr(u));\n exp = Math.pow(exp, p);\n uArray[i] = un.substr(0, u) + exp.toString();\n u = -1;\n }\n else {\n uArray[i] += p.toString();\n u = -1;\n } // end if there are/aren't some numbers at the end\n u = -1;\n } // end if this character is not a number\n } // end searching backwards for start of exponent\n } // end if this element is not a number\n } // end if the current element is not an operator\n } // end do for each element of the units array\n\n // reassemble the updated units array to a string\n retUnit.csCode_ = uArray.join('');\n\n retUnit.magnitude_ = Math.pow(this.magnitude_, p);\n if (retUnit.dim_) {\n retUnit.dim_.mul(p);\n }\n\n // Also update equivalentExp_ and moleExp\n retUnit.equivalentExp_ *= p;\n retUnit.moleExp_ *= p;\n\n return retUnit;\n\n } // end power\n\n\n /*\n * This function tests this unit against the unit passed in to see if the\n * two are mole to mass commensurable. It assumes that one of the units\n * is a mole-based unit and the other is a mass-based unit. It also assumes\n * that the mole-based unit has a single mole unit in the numerator and that\n * the mass-based unit has a single mass unit in the numerator. It does NOT\n * check to validate those assumptions.\n *\n * The check is made by setting the dimension vector element corresponding\n * to the base mass unit (gram) in the mole unit, and then comparing the\n * two dimension vectors. If they match, the units are commensurable.\n * Otherwise they are not.\n *\n * @param unit2 the unit to be compared to this one\n * @returns boolean indicating commensurability\n */\n isMolMassCommensurable(unit2) {\n let tabs = this._getUnitTables();\n let d = tabs.getMassDimensionIndex();\n // Add the moleExp_ values to the mass values in the dimension vectors\n // of each unit, and then compare them.\n const unit1Dim = this.dim_.clone();\n unit1Dim.setElementAt(d, (unit1Dim.getElementAt(d) + this.moleExp_));\n const unit2Dim = unit2.dim_.clone();\n unit2Dim.setElementAt(d, (unit2Dim.getElementAt(d) + unit2.moleExp_));\n return (unit1Dim.equals(unit2Dim));\n }\n\n\n /**\n * This function tests this unit against the unit passed in to see if the\n * two are eq to mass commensurable. It assumes that one of the units\n * is a eq-based unit and the other is a mass-based unit. It also assumes\n * that the eq-based unit has a single eq unit in the numerator and that\n * the mass-based unit has a single mass unit in the numerator. It does NOT\n * check to validate those assumptions.\n *\n * The check is made by setting the dimension vector element corresponding\n * to the base mass unit (gram) in the eq unit, and then comparing the\n * two dimension vectors. If they match, the units are commensurable.\n * Otherwise they are not.\n *\n * @param {Unit} unit2 the unit to be compared to this one\n * @returns {boolean} boolean indicating commensurability\n */\n isEqMassCommensurable(unit2) {\n let tabs = this._getUnitTables();\n let d = tabs.getMassDimensionIndex();\n // Add the equivalentExp_ values to the mass values in the dimension vectors\n // of each unit, and then compare them.\n const unit1Dim = this.dim_.clone();\n unit1Dim.setElementAt(d, (unit1Dim.getElementAt(d) + this.equivalentExp_));\n const unit2Dim = unit2.dim_.clone();\n unit2Dim.setElementAt(d, (unit2Dim.getElementAt(d) + unit2.equivalentExp_));\n return (unit1Dim.equals(unit2Dim));\n }\n\n /**\n * This function tests this unit against the unit passed in to see if the\n * two are eq to mass commensurable-- that the equivalents could be converted\n * to the mass or vice-versa, in a way that makes the units commensurable.\n *\n * The check is made by adding the mole dimension to the equivalent dimension\n * and comparing that result for the two units, along with the units'\n * dimension vectors. If they match, the units are\n * commensurable. Otherwise they are not.\n *\n * @param {Unit} unit2 the unit to be compared to this one\n * @returns {boolean} boolean indicating commensurability\n */\n isEqMolCommensurable(unit2) {\n const unit1Sum = this.equivalentExp_ + this.moleExp_;\n const unit2Sum = unit2.equivalentExp_ + unit2.moleExp_;\n return unit1Sum == unit2Sum && this.dim_.equals(unit2.dim_);\n }\n\n\n /**\n * This function tests this unit against the unit passed in to see if the\n * two are commensurable if eq, mol, and mass units are converted in some\n * direction.\n *\n * The check is made by adding the eq, mol, and mass dimensions\n * and comparing that result for the two units, along with the units'\n * dimension vectors. If they match, the units are\n * commensurable. Otherwise they are not.\n *\n * @param {Unit} unit2 the unit to be compared to this one\n * @returns {boolean} boolean indicating commensurability\n */\n isEqMolMassCommensurable(unit2) {\n const d = this._getUnitTables().getMassDimensionIndex();\n const unit1Dim = this.dim_.clone();\n unit1Dim.setElementAt(d, unit1Dim.getElementAt(d) + this.equivalentExp_ +\n this.moleExp_);\n const unit2Dim = unit2.dim_.clone();\n unit2Dim.setElementAt(d, unit2Dim.getElementAt(d) + unit2.equivalentExp_ +\n unit2.moleExp_);\n return unit1Dim.equals(unit2Dim);\n }\n\n\n /**\n * This returns the UnitTables singleton object. Including the require\n * statement included here causes a circular dependency condition that\n * resulted in the UnitTables object not being defined for the Unit object.\n * sigh. Thanks, Paul, for figuring this out.\n *\n * @private\n */\n _getUnitTables() {\n if (!UnitTables)\n UnitTables = require('./unitTables.js').UnitTables;\n return UnitTables.getInstance();\n }\n\n} // end Unit class\n"],"mappings":";;;;;;AAYA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAoD,SAAAG,yBAAA,eAAAC,OAAA,kCAAAC,KAAA,OAAAD,OAAA,IAAAD,wBAAA,YAAAA,CAAA,WAAAE,KAAA,YAAAA,KAAA;AAAA,SAAAH,wBAAAI,GAAA,QAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAD,KAAA,GAAAF,wBAAA,QAAAE,KAAA,IAAAA,KAAA,CAAAI,GAAA,CAAAH,GAAA,YAAAD,KAAA,CAAAK,GAAA,CAAAJ,GAAA,SAAAK,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAV,GAAA,QAAAO,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAb,GAAA,EAAAU,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAT,GAAA,E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