@lhncbc/ucum-lhc 5.0.0 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -12
- package/browser-dist/ucum-lhc.js +731 -1265
- package/data/ucumDefs.min.json +1 -1
- package/package.json +1 -1
- package/source/ucumLhcUtils.js +2 -2
- package/source/ucumXmlDocument.js +5 -2
- package/source/unit.js +2 -1
- package/source/unitString.js +142 -130
- package/source-cjs/config.js +1 -12
- package/source-cjs/config.js.map +1 -1
- package/source-cjs/dimension.js +20 -63
- package/source-cjs/dimension.js.map +1 -1
- package/source-cjs/jsonArrayPack.js +7 -25
- package/source-cjs/jsonArrayPack.js.map +1 -1
- package/source-cjs/prefix.js +12 -26
- package/source-cjs/prefix.js.map +1 -1
- package/source-cjs/prefixTables.js +10 -24
- package/source-cjs/prefixTables.js.map +1 -1
- package/source-cjs/ucumFunctions.js +35 -32
- package/source-cjs/ucumFunctions.js.map +1 -1
- package/source-cjs/ucumInternalUtils.js +5 -13
- package/source-cjs/ucumInternalUtils.js.map +1 -1
- package/source-cjs/ucumJsonDefs.js +1 -16
- package/source-cjs/ucumJsonDefs.js.map +1 -1
- package/source-cjs/ucumLhcUtils.js +28 -92
- package/source-cjs/ucumLhcUtils.js.map +1 -1
- package/source-cjs/ucumPkg.js +1 -6
- package/source-cjs/ucumPkg.js.map +1 -1
- package/source-cjs/ucumXmlDocument.js +162 -184
- package/source-cjs/ucumXmlDocument.js.map +1 -1
- package/source-cjs/unit.js +97 -181
- package/source-cjs/unit.js.map +1 -1
- package/source-cjs/unitString.js +521 -608
- package/source-cjs/unitString.js.map +1 -1
- package/source-cjs/unitTables.js +33 -139
- package/source-cjs/unitTables.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/unitTables.js"],"names":["Ucum","require","UnitTablesFactory","constructor","unitNames_","unitCodes_","codeOrder_","unitStrings_","unitDimensions_","unitSynonyms_","massDimIndex_","dimVecIndexToBaseUnit_","unitsCount","Object","keys","length","addUnit","theUnit","uName","addUnitName","addUnitCode","addUnitString","getProperty","addUnitDimension","err","isBase_","dimVec","dim_","dimVec_","nonZeroIndex","i","len","undefined","csCode_","push","Error","uCode","d","uString","caseSensitive_","uEntry","mag","unit","uDim","buildUnitSynonyms","code","uSyns","synonyms_","synsAry","split","aLen","a","theSyn","trim","addSynonymCodes","name_","theCode","theSynonyms","words","wLen","w","word","synCodes","indexOf","getUnitByCode","retUnit","getUnitByName","sepPos","codeSep_","substr","retUnits","uLen","getUnitByString","retAry","getUnitsByDimension","unitsArray","console","log","getUnitBySynonym","uSyn","retObj","foundCodes","fLen","f","message","getAllUnitNames","getUnitNamesList","nameList","codes","sort","compareCodes","getMassDimensionIndex","b","replace","toLowerCase","getAllUnitCodes","allUnitsByDef","unitsList","u","allUnitsByName","cols","sep","unitBuff","cLen","nameRecs","rec","c","Array","join","cbuf","printUnits","doLong","codeList","unitString","curUnit","curDim","csUnitString_","baseFactor_","cnv_","defError_","unitTablesInstance","UnitTables","getInstance"],"mappings":";;;;;;;AAAA;;;;;;;AAQA,IAAIA,IAAI,GAAGC,OAAO,CAAC,aAAD,CAAP,CAAuBD,IAAlC;;AAEA,MAAME,iBAAN,CAAwB;AAEtB;;;;;;;;;;;;;;;;;;;AAmBAC,EAAAA,WAAW,GAAG;AAEZ;;;;;;;;AAQA,SAAKC,UAAL,GAAkB,EAAlB;AAEA;;;;;;;;AAOA,SAAKC,UAAL,GAAkB,EAAlB;AAEA;;;;;;;AAMA,SAAKC,UAAL,GAAkB,EAAlB;AAEA;;;;;;;AAMA,SAAKC,YAAL,GAAoB,EAApB;AAEA;;;;;;;;;;;AAUA,SAAKC,eAAL,GAAuB,EAAvB;AAEA;;;;;;;;AAOC,SAAKC,aAAL,GAAqB,EAArB;AAED;;;;;;;;;;AASA,SAAKC,aAAL,GAAqB,CAArB;AAEA;;;;AAGA,SAAKC,sBAAL,GAA8B,EAA9B;AACD;AAG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IAAR,GAAejB,GAA7B,CADF,KAGEY,UAAU,IAAI,SAASZ,GAAvB;;AAEF,UAAIU,MAAJ,EAAY;AACVE,QAAAA,UAAU,IAAIC,OAAO,CAAC5F,WAAR,CAAoB,WAApB,IAAmC+E,GAAnC,GACAa,OAAO,CAAC5F,WAAR,CAAoB,cAApB,CADA,GACsC+E,GADtC,GAEAa,OAAO,CAAC5F,WAAR,CAAoB,WAApB,CAFA,GAEmC+E,GAFnC,GAGAa,OAAO,CAAC5F,WAAR,CAAoB,SAApB,CAHA,GAGiC+E,GAHjC,GAIAa,OAAO,CAAC5F,WAAR,CAAoB,QAApB,CAJA,GAIgC+E,GAJhC,GAKAa,OAAO,CAAC5F,WAAR,CAAoB,WAApB,CALA,GAKmC+E,GALnC,GAMAa,OAAO,CAAC5F,WAAR,CAAoB,WAApB,CANA,GAMmC+E,GANnC,GAOAa,OAAO,CAAC5F,WAAR,CAAoB,YAApB,CAPA,GAOoC+E,GAPpC,GAQAa,OAAO,CAAC5F,WAAR,CAAoB,cAApB,CARA,GAQsC+E,GARpD;AASD;;AACD,UAAIa,OAAO,CAACK,SAAZ,EACEN,UAAU,IAAI,8CAAd;AACFD,MAAAA,QAAQ,IAAIC,UAAU,GAAG,IAAzB;AACD;;AACD,WAAOD,QAAP;AACD;;AAxsBqB,C,CA0sBtB;AAGF;AACA;;;AACA,IAAIQ,kBAAkB,GAAG,IAAItH,iBAAJ,EAAzB;AACO,MAAMuH,UAAU,GAAG;AACxBC,EAAAA,WAAW,EAAE,YAAW;AACtB,WAAOF,kBAAP;AACD;AAHuB,CAAnB","sourcesContent":["/**\n * This class manages Hashtables that provide references to\n * defined units.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\n\nvar Ucum = require('./config.js').Ucum;\n\nclass UnitTablesFactory {\n\n /**\n * Constructor. This creates the empty unit tables (hashes) once. After the\n * tables are created, it redefines this constructor to throw an error\n * stating that the constructor is no longer available and that the\n * getInstance function must be used. Here's a description of the first\n * and then all subsequent calls to this constructor.\n *\n * First call to constructor:\n * 1. creates OBJECT1\n * 2. initializes attributes of OBJECT1\n * 3. stores reference to OBJECT1.prototype in holdthis local variable\n * 4. redefines OBJECT1 as a function that throws an error\n * 5. defines the getInstance function (which is also defined outside of\n * the class definition - see below).\n *\n * All subsequent calls to constructor:\n * 1. throw error message referring to getInstance\n * 2. call getInstance, returns this - which is OBJECT1.\n */\n constructor() {\n\n /**\n * Tracks units by name\n * @type hash - key is the name;\n * value is an array of references to the Unit objects\n * with the name. More than one unit may have the same\n * name, e.g., \"second\", which is shared by the base unit\n * with the code = \"s\" and the unit with code = \"'\".\n */\n this.unitNames_ = {};\n\n /**\n * Tracks units by code using case-sensitive version.\n *\n * @type hash - key is the code;\n * value is the reference to the Unit object. Codes must\n * be unique.\n */\n this.unitCodes_ = {};\n\n /**\n * Keeps track of the order in which units are defined. The order is\n * important because unit definitions build on previous definitions.\n *\n * @type {Array}\n */\n this.codeOrder_ = [] ;\n\n /**\n * Tracks units by unit strings, e.g., cm-1\n *\n * @type hash - key is the unit string\n * value is an array of unit objects with that ciUnitString.\n */\n this.unitStrings_ = {};\n\n /**\n * Tracks units by Dimension vector\n *\n * @type hash - key is the dimension vector (not the object, just the\n * vector);\n * value is an array of references to the Unit objects\n * with that vector. More than one unit may have the same\n * unit vector, and this can be used to provide a list\n * of commensurable units.\n */\n this.unitDimensions_ = {};\n\n /**\n * Maps synonyms to units. Not built until first requested.\n *\n * @type hash - key is the synonym\n * value is an array of references to Unit objects that\n * include that synonym.\n */\n this.unitSynonyms_ = {};\n\n /*\n * Holds onto the index of the index of the dimension vector flag for\n * the base mass unit (gram). This is set when the base unit (gram) is\n * created, and is stored here so that it doesn't have to be found\n * over and over again to try to determine whether or not a unit is\n * mass-based (for mole<->mass conversions)\n *\n * @type integer\n */\n this.massDimIndex_ = 0;\n\n /**\n * Map of indices in the dimension vector to base unit symbols.\n */\n this.dimVecIndexToBaseUnit_ = {};\n }\n\n\n /**\n * Provides the number of unit objects written to the tables, using the\n * codes table since codes must be unique.\n *\n * @returns count of the number of unit objects in the unitCodes_ table.\n */\n unitsCount() {\n return Object.keys(this.unitCodes_).length ;\n }\n\n\n /**\n * Adds a Unit object to the tables.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws passes on an error if one is thrown by the called functions for\n * a problem with the unit code or unit name\n */\n addUnit(theUnit) {\n\n let uName = theUnit['name_'] ;\n if (uName) {\n this.addUnitName(theUnit);\n }\n\n this.addUnitCode(theUnit);\n this.addUnitString(theUnit);\n\n try {\n if (theUnit['dim_'].getProperty('dimVec_'))\n this.addUnitDimension(theUnit);\n }\n catch(err){\n // do nothing - throws error if the property is null\n // and that's OK here.\n }\n\n if (theUnit.isBase_) {\n const dimVec = theUnit.dim_.dimVec_;\n let nonZeroIndex;\n for (let i=0, len=dimVec.length; nonZeroIndex==undefined && i<len; ++i) {\n if (dimVec[i] != 0)\n nonZeroIndex = i;\n }\n this.dimVecIndexToBaseUnit_[nonZeroIndex] = theUnit.csCode_;\n }\n } // end addUnit\n\n\n /**\n * Adds a Unit object to the unitNames_ table. More than one unit\n * can have the same name, e.g., the two units with the name \"second\",\n * where the code for one of them is 's' and the code for the other is\n * \"'\". Because of this, an array of unit objects is stored for the\n * name. In most cases it will be an array of one object, but this\n * clarifies that there may be more than one.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws an error if the unit has no name\n */\n addUnitName(theUnit) {\n\n let uName = theUnit['name_'];\n\n if (uName) {\n if (this.unitNames_[uName])\n this.unitNames_[uName].push(theUnit);\n else\n this.unitNames_[uName] = [theUnit];\n }\n else\n throw(new Error('UnitTables.addUnitName called for a unit with no name. ' +\n `Unit code = ${theUnit['csCode_']}.`));\n\n } // end addUnitName\n\n\n /**\n * Adds a Unit object to the unitCodes_, unitUcCodes_, unitLcCodes_ and\n * codeOrder_ tables. This also sets the mass dimension index when the\n * base mass unit (gram) is read.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws an error if the unitCodes_ table already contains a unit with\n * the code\n */\n addUnitCode(theUnit) {\n\n let uCode = theUnit['csCode_'];\n if (uCode) {\n\n if (this.unitCodes_[uCode])\n throw(new Error(`UnitTables.addUnitCode called, already contains entry for ` +\n `unit with code = ${uCode}`));\n else {\n this.unitCodes_[uCode] = theUnit;\n this.codeOrder_.push(uCode);\n if (uCode == 'g') {\n let dimVec = theUnit.dim_.dimVec_;\n let d = 0;\n for (; d < dimVec.length && dimVec[d] < 1; d++) ;\n this.massDimIndex_ = d;\n }\n }\n }\n else\n throw(new Error('UnitTables.addUnitCode called for unit that has ' +\n 'no code.')) ;\n\n } // end addUnitCode\n\n\n /**\n * Adds a unit object to the unitStrings_ table. More than one unit\n * can have the same string, so an array of unit objects is stored\n * for the string. The unit string is the string that creates a non-base\n * unit, e.g., a Newton has a unit code of N, a name of Newton, and a\n * unitString of kg.m/s2.\n *\n * If the unit has no string, nothing is stored and no error is reported.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n */\n addUnitString(theUnit) {\n\n let uString = null;\n if (Ucum.caseSensitive_ == true)\n uString = theUnit['csUnitString_'];\n else\n uString = theUnit['ciUnitString_'];\n\n if (uString) {\n let uEntry = {mag: theUnit['baseFactorStr_'], unit: theUnit};\n if (this.unitStrings_[uString])\n this.unitStrings_[uString].push(uEntry);\n else\n this.unitStrings_[uString] = [uEntry];\n }\n } // end addUnitString\n\n\n /**\n * Adds a Unit object to the unitDimensions_ table. More than one unit\n * can have the same dimension (commensurable units have the same dimension).\n * Because of this, an array of unit objects is stored for the\n * dimension.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws an error if the unit has no dimension\n */\n addUnitDimension(theUnit) {\n\n let uDim = theUnit['dim_'].getProperty('dimVec_');\n\n if (uDim) {\n if (this.unitDimensions_[uDim])\n this.unitDimensions_[uDim].push(theUnit);\n else\n this.unitDimensions_[uDim] = [theUnit];\n }\n else\n throw(new Error('UnitTables.addUnitDimension called for a unit with no dimension. ' +\n `Unit code = ${theUnit['csCode_']}.`));\n\n } // end addUnitDimension\n\n\n /**\n * Builds the unitSynonyms_ table. This is called the first time the\n * getUnitsBySynonym method is called. The table/hash contains each word\n * (once) from each synonym as well as each word from each unit name.\n *\n * Hash keys are the words. Hash values are an array of unit codes for\n * each unit that has that word in its synonyms or name.\n *\n * @returns nothing\n */\n buildUnitSynonyms() {\n\n for (let code in this.unitCodes_) {\n let theUnit = this.unitCodes_[code];\n let uSyns = theUnit.synonyms_ ;\n\n // If the current unit has synonyms, process each synonym (often multiples)\n if (uSyns) {\n let synsAry = uSyns.split(';');\n if (synsAry[0] !== '') {\n let aLen = synsAry.length;\n for (let a = 0; a < aLen; a++) {\n let theSyn = synsAry[a].trim();\n\n // call addSynonymCodes to process each word in the\n // synonym, e.g., \"British fluid ounces\"\n this.addSynonymCodes(code, theSyn) ;\n } // end do for each synonym\n } // end if the current unit has a non-null synonym attribute\n } // end if the unit has any synonyms\n\n // Now call addSynonymCodes to process each word in the unit's name\n this.addSynonymCodes(code, theUnit.name_) ;\n } // end do for each unit\n } // end buildUnitSynonyms\n\n\n /**\n * Adds unit code entries to the synonyms table for a string containing\n * one or more words to be considered as synonyms.\n *\n * @param theCode the unit code to be connected to the synonyms\n * @param theSynonyms a string containing one or more words to be\n * considered synonyms (and thus to be added to the unitSynonyms hash).\n */\n addSynonymCodes(theCode, theSynonyms) {\n\n let words = theSynonyms.split(' ');\n let wLen = words.length;\n\n for (let w = 0; w < wLen; w++) {\n let word = words[w];\n\n // if there is already a synonyms entry for the word,\n // get the array of unit codes currently assigned to\n // the word and add the code for the current word to\n // the synonyms array if it's not already there.\n if (this.unitSynonyms_[word]) {\n let synCodes = this.unitSynonyms_[word];\n if (synCodes.indexOf(theCode) === -1) {\n this.unitSynonyms_[word].push(theCode);\n }\n }\n // else there are no synonyms entry for the word. Create a\n // synonyms array for the word, setting it to contain the unit code.\n else {\n this.unitSynonyms_[word] = [theCode];\n }\n } // end do for each word in the synonyms being processed\n\n } // end addSynonymCodes\n\n\n /**\n * Returns a unit object with a case-sensitive code matching the\n * uCode parameter, or null if no unit is found with that code.\n *\n * @param uCode the code of the unit to be returned\n * @returns the unit object or null if it is not found\n */\n getUnitByCode(uCode) {\n let retUnit = null ;\n if (uCode) {\n retUnit = this.unitCodes_[uCode];\n }\n return retUnit ;\n }\n\n\n /**\n * Returns a array of unit objects based on the unit's name. Usually this\n * will be an array of one, but there may be more, since unit names are\n * not necessarily unique.\n *\n * @param uName the name of the unit to be returned. If more than one\n * unit has the same name and you only want one specific unit, append the\n * csCode of the unit you want to the end of the name, separated by the\n * Ucum.codeSep_ value, e.g., inch - [in_i] vs. inch - [in_us].\n * @returns null if no unit was found for the specified name OR an array of\n * unit objects with the specified name. Normally this will be an array\n * of one object.\n * @throws an error if no name is provided to search on\n */\n getUnitByName(uName) {\n\n if (uName === null || uName === undefined) {\n throw (new Error('Unable to find unit by name because no name was provided.'));\n }\n let sepPos = uName.indexOf(Ucum.codeSep_);\n let uCode = null;\n if (sepPos >= 1) {\n uCode = uName.substr(sepPos + Ucum.codeSep_.length);\n uName = uName.substr(0, sepPos);\n }\n let retUnits = this.unitNames_[uName] ;\n if (retUnits) {\n let uLen = retUnits.length ;\n\n if (uCode && uLen > 1) {\n let i = 0;\n for (; retUnits[i].csCode_ !== uCode && i < uLen; i++);\n if (i < uLen)\n retUnits = [retUnits[i]];\n else {\n retUnits = null;\n }\n } // end if we need to find both a name and a code\n } // end if we got an array of units\n return retUnits ;\n\n } // end getUnitByName\n\n\n /**\n * Returns an array of unit objects with the specified unit string.\n * The array may contain one or more unit reference objects.\n * Or none, if no units have a matching unit string (which is not\n * considered an error)\n *\n * @param name the name of the unit to be returned\n * @returns the array of unit references or null if none were found\n */\n getUnitByString(uString) {\n let retAry = null ;\n if (uString) {\n retAry = this.unitStrings_[uString] ;\n if (retAry === undefined)\n retAry = null;\n }\n return retAry ;\n }\n\n\n /**\n * Returns a array of unit objects based on the unit's dimension vector.\n *\n * @param uName the dimension vector of the units to be returned.\n *\n * @returns null if no unit was found for the specified vector OR an array of\n * one or more unit objects with the specified vector.\n * @throws an error if no vector is provided to search on\n * logs an error to the console if no unit is found\n */\n getUnitsByDimension(uDim) {\n\n let unitsArray = null ;\n if (uDim === null || uDim === undefined) {\n throw (new Error('Unable to find unit by because no dimension ' +\n 'vector was provided.'));\n }\n\n unitsArray = this.unitDimensions_[uDim] ;\n if (unitsArray === undefined || unitsArray === null) {\n console.log(`Unable to find unit with dimension = ${uDim}`);\n }\n\n return unitsArray ;\n\n } // end getUnitsByDimension\n\n\n /**\n * Returns a array of unit objects that include the specified synonym.\n *\n * @param uSyn the synonym of the units to be returned.\n *\n * @returns an object with two of the following three elements:\n * 'status' will be error, failed or succeeded\n * 'msg' will be included for returns with status = error or failed and\n * will explain why the request did not return any units\n * 'units' any array of unit objects with the specified synonym will be\n * returned for requests with status = succeeded\n */\n getUnitBySynonym(uSyn) {\n\n let retObj = {} ;\n let unitsArray = [];\n\n try {\n if (uSyn === null || uSyn === undefined) {\n retObj['status'] = 'error' ;\n throw (new Error('Unable to find unit by synonym because no synonym ' +\n 'was provided.'));\n }\n // If this is the first request for a unit by synonym, build the hash map\n if (Object.keys(this.unitSynonyms_).length === 0) {\n this.buildUnitSynonyms();\n }\n let foundCodes = [];\n foundCodes = this.unitSynonyms_[uSyn];\n if (foundCodes) {\n retObj['status'] = 'succeeded';\n let fLen = foundCodes.length;\n for (let f = 0; f < fLen; f++) {\n unitsArray.push(this.unitCodes_[foundCodes[f]]);\n }\n retObj['units'] = unitsArray ;\n }\n if (unitsArray.length === 0) {\n retObj['status'] = 'failed' ;\n retObj['msg'] = `Unable to find any units with synonym = ${uSyn}`;\n }\n }\n catch(err) {\n retObj['msg'] = err.message ;\n }\n return retObj ;\n } // end getUnitBySynonym\n\n\n /**\n * Gets a list of all unit names in the Unit tables\n *\n * @returns an array of the unit names\n */\n getAllUnitNames() {\n return Object.keys(this.unitNames_);\n } // end getAllUnitNames\n\n\n /**\n * Gets a list of all unit names in the tables. Where more than one\n * unit has the same name, the unit code, in parentheses, is appended\n * to the end of the name.\n *\n * @returns {Array}\n */\n getUnitNamesList() {\n let nameList = [];\n let codes = Object.keys(this.unitCodes_);\n codes.sort(this.compareCodes) ;\n let uLen = codes.length;\n for (let i = 0; i < uLen; i++) {\n nameList[i] = codes[i] + Ucum.codeSep_ + this.unitCodes_[codes[i]].name_\n } // end do for each code\n return nameList ;\n }\n\n\n /*\n * Returns the mass dimension index\n * @returns this.massDimIndex_\n */\n getMassDimensionIndex() {\n return this.massDimIndex_ ;\n }\n\n /**\n * This provides a sort function for unit codes so that sorting ignores\n * square brackets and case.\n *\n * @param a first value\n * @param b second value\n * @returns -1 if a is should fall before b; otherwise 1.\n */\n compareCodes(a, b) {\n a = a.replace(/[\\[\\]]/g, '');\n a = a.toLowerCase();\n b = b.replace(/[\\[\\]]/g, '');\n b = b.toLowerCase();\n return (a < b) ? -1 : 1 ;\n }\n\n\n /**\n * Gets a list of all unit codes in the Unit tables\n *\n * @returns an array of the unit names\n */\n getAllUnitCodes() {\n return Object.keys(this.unitCodes_);\n } // end getAllUnitNames\n\n\n /**\n * This is used to get all unit objects. Currently it is used\n * to get the objects to write to the json ucum definitions file\n * that is used to provide prefix and unit definition objects for\n * conversions and validations.\n *\n * @returns an array containing all unit objects, ordered by definition\n * order\n */\n allUnitsByDef() {\n\n let unitsList = [];\n let uLen = this.codeOrder_.length ;\n for (let u = 0; u < uLen; u++) {\n unitsList.push(this.getUnitByCode(this.codeOrder_[u]));\n }\n return unitsList ;\n } // end allUnitsByDef\n\n\n /**\n * This is used to get all unit objects, ordered by unit name. Currently it\n * is used to create a csv list of all units.\n * @param sep separator character (or string) to be used to separate each\n * column in the output. Optional, defaults to '|' if not specified.\n * (Used to use ; but the synonyms use that extensively). Don't use a\n * comma or any other punctuation found in the output data.\n * @returns a buffer containing all unit objects, ordered by name\n * order\n */\n allUnitsByName(cols, sep) {\n if (sep === undefined || sep === null)\n sep = '|';\n let unitBuff = '';\n let unitsList = this.getAllUnitNames();\n let uLen = unitsList.length;\n let cLen = cols.length;\n for (let i = 0; i < uLen; i++) {\n let nameRecs = this.getUnitByName(unitsList[i]);\n for (let u = 0; u < nameRecs.length; u++) {\n let rec = nameRecs[u];\n for (let c = 0; c < cLen; c++) {\n if (c > 0)\n unitBuff += sep;\n if (cols[c] === 'dim_') {\n if (rec.dim_ !== null && rec.dim_ !== undefined &&\n rec.dim_.dimVec_ instanceof Array)\n unitBuff += '[' + rec.dim_.dimVec_.join(',') + ']';\n else\n unitBuff += '';\n }\n else {\n let cbuf = rec[cols[c]];\n if (typeof cbuf === 'string')\n unitBuff += cbuf.replace(/[\\n\\r]/g, ' ');\n else\n unitBuff += cbuf ;\n }\n } // end do for each column requested\n unitBuff += '\\r\\n';\n } // end do for each unit in the unit names array\n }\n return unitBuff ;\n } // end allUnitsByName\n\n\n /**\n * This creates a list of all units in the tables. It uses the byCode\n * table, and uses the codeOrder_ array to determine the order in which\n * the units are listed.\n *\n * @param doLong boolean indicating how much to output. If true, all data\n * from the unit objects is included. If false, only a few major values\n * are included.\n * @param sep separator character (or string) to be used to separate each\n * column in the output. Optional, defaults to '|' if not specified.\n * (Used to use ; but the synonyms use that extensively).\n * @returns {string} buffer containing all the listings\n */\n printUnits(doLong, sep) {\n if (doLong === undefined)\n doLong = false ;\n if (sep === undefined)\n sep = '|';\n let codeList = '';\n let uLen = this.codeOrder_.length ;\n let unitString = 'csCode' + sep ;\n if (doLong) {\n unitString += 'ciCode' + sep ;\n }\n unitString += 'name' + sep ;\n if (doLong)\n unitString += 'isBase' + sep ;\n unitString += 'magnitude' + sep + 'dimension' + sep + 'from unit(s)' + sep +\n 'value' + sep + 'function' + sep ;\n if (doLong)\n unitString += 'property' + sep + 'printSymbol' + sep + 'synonyms' + sep +\n 'source' + sep + 'class' + sep + 'isMetric' + sep +\n 'variable' + sep + 'isSpecial' + sep + 'isAbitrary' + sep ;\n unitString += 'comment';\n codeList = unitString + '\\n' ;\n\n for (let u = 0; u < uLen; u++) {\n let curUnit = this.getUnitByCode(this.codeOrder_[u]);\n unitString = this.codeOrder_[u] + sep ;\n if (doLong) {\n unitString += curUnit.getProperty('ciCode_') + sep ;\n }\n unitString += curUnit.getProperty('name_') + sep ;\n if (doLong) {\n if (curUnit.getProperty('isBase_'))\n unitString += 'true' + sep ;\n else\n unitString += 'false' + sep ;\n }\n unitString += curUnit.getProperty('magnitude_') + sep;\n let curDim = curUnit.getProperty('dim_');\n if (curDim) {\n unitString += curDim.dimVec_ + sep ;\n }\n else {\n unitString += 'null' + sep;\n }\n if (curUnit.csUnitString_)\n unitString += curUnit.csUnitString_ + sep + curUnit.baseFactor_ + sep ;\n else\n unitString += 'null' + sep + 'null' + sep;\n\n if (curUnit.cnv_)\n unitString += curUnit.cnv_ + sep ;\n else\n unitString += 'null' + sep ;\n\n if (doLong) {\n unitString += curUnit.getProperty('property_') + sep +\n curUnit.getProperty('printSymbol_') + sep +\n curUnit.getProperty('synonyms_') + sep +\n curUnit.getProperty('source_') + sep +\n curUnit.getProperty('class_') + sep +\n curUnit.getProperty('isMetric_') + sep +\n curUnit.getProperty('variable_') + sep +\n curUnit.getProperty('isSpecial_') + sep +\n curUnit.getProperty('isArbitrary_') + sep ;\n }\n if (curUnit.defError_)\n unitString += 'problem parsing this one, deferred to later.' ;\n codeList += unitString + '\\n' ;\n }\n return codeList ;\n }\n\n} // end UnitTablesFactory\n\n\n// Create a singleton instance and (to preserve the existing API) an object that\n// provides that instance via getInstance().\nvar unitTablesInstance = new UnitTablesFactory();\nexport const UnitTables = {\n getInstance: function() {\n return unitTablesInstance;\n }\n}\n"],"file":"unitTables.js"}
|
|
1
|
+
{"version":3,"file":"unitTables.js","names":["Ucum","require","UnitTablesFactory","constructor","unitNames_","unitCodes_","codeOrder_","unitStrings_","unitDimensions_","unitSynonyms_","massDimIndex_","dimVecIndexToBaseUnit_","unitsCount","Object","keys","length","addUnit","theUnit","uName","addUnitName","addUnitCode","addUnitString","getProperty","addUnitDimension","err","isBase_","dimVec","dim_","dimVec_","nonZeroIndex","i","len","undefined","csCode_","push","Error","uCode","d","uString","caseSensitive_","uEntry","mag","unit","uDim","buildUnitSynonyms","code","uSyns","synonyms_","synsAry","split","aLen","a","theSyn","trim","addSynonymCodes","name_","theCode","theSynonyms","words","wLen","w","word","synCodes","indexOf","getUnitByCode","retUnit","getUnitByName","sepPos","codeSep_","substr","retUnits","uLen","getUnitByString","retAry","getUnitsByDimension","unitsArray","console","log","getUnitBySynonym","uSyn","retObj","foundCodes","fLen","f","message","getAllUnitNames","getUnitNamesList","nameList","codes","sort","compareCodes","getMassDimensionIndex","b","replace","toLowerCase","getAllUnitCodes","allUnitsByDef","unitsList","u","allUnitsByName","cols","sep","unitBuff","cLen","nameRecs","rec","c","Array","join","cbuf","printUnits","doLong","codeList","unitString","curUnit","curDim","csUnitString_","baseFactor_","cnv_","defError_","unitTablesInstance","UnitTables","getInstance","exports"],"sources":["../source/unitTables.js"],"sourcesContent":["/**\n * This class manages Hashtables that provide references to\n * defined units.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\n\nvar Ucum = require('./config.js').Ucum;\n\nclass UnitTablesFactory {\n\n /**\n * Constructor. This creates the empty unit tables (hashes) once. After the\n * tables are created, it redefines this constructor to throw an error\n * stating that the constructor is no longer available and that the\n * getInstance function must be used. Here's a description of the first\n * and then all subsequent calls to this constructor.\n *\n * First call to constructor:\n * 1. creates OBJECT1\n * 2. initializes attributes of OBJECT1\n * 3. stores reference to OBJECT1.prototype in holdthis local variable\n * 4. redefines OBJECT1 as a function that throws an error\n * 5. defines the getInstance function (which is also defined outside of\n * the class definition - see below).\n *\n * All subsequent calls to constructor:\n * 1. throw error message referring to getInstance\n * 2. call getInstance, returns this - which is OBJECT1.\n */\n constructor() {\n\n /**\n * Tracks units by name\n * @type hash - key is the name;\n * value is an array of references to the Unit objects\n * with the name. More than one unit may have the same\n * name, e.g., \"second\", which is shared by the base unit\n * with the code = \"s\" and the unit with code = \"'\".\n */\n this.unitNames_ = {};\n\n /**\n * Tracks units by code using case-sensitive version.\n *\n * @type hash - key is the code;\n * value is the reference to the Unit object. Codes must\n * be unique.\n */\n this.unitCodes_ = {};\n\n /**\n * Keeps track of the order in which units are defined. The order is\n * important because unit definitions build on previous definitions.\n *\n * @type {Array}\n */\n this.codeOrder_ = [] ;\n\n /**\n * Tracks units by unit strings, e.g., cm-1\n *\n * @type hash - key is the unit string\n * value is an array of unit objects with that ciUnitString.\n */\n this.unitStrings_ = {};\n\n /**\n * Tracks units by Dimension vector\n *\n * @type hash - key is the dimension vector (not the object, just the\n * vector);\n * value is an array of references to the Unit objects\n * with that vector. More than one unit may have the same\n * unit vector, and this can be used to provide a list\n * of commensurable units.\n */\n this.unitDimensions_ = {};\n\n /**\n * Maps synonyms to units. Not built until first requested.\n *\n * @type hash - key is the synonym\n * value is an array of references to Unit objects that\n * include that synonym.\n */\n this.unitSynonyms_ = {};\n\n /*\n * Holds onto the index of the index of the dimension vector flag for\n * the base mass unit (gram). This is set when the base unit (gram) is\n * created, and is stored here so that it doesn't have to be found\n * over and over again to try to determine whether or not a unit is\n * mass-based (for mole<->mass conversions)\n *\n * @type integer\n */\n this.massDimIndex_ = 0;\n\n /**\n * Map of indices in the dimension vector to base unit symbols.\n */\n this.dimVecIndexToBaseUnit_ = {};\n }\n\n\n /**\n * Provides the number of unit objects written to the tables, using the\n * codes table since codes must be unique.\n *\n * @returns count of the number of unit objects in the unitCodes_ table.\n */\n unitsCount() {\n return Object.keys(this.unitCodes_).length ;\n }\n\n\n /**\n * Adds a Unit object to the tables.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws passes on an error if one is thrown by the called functions for\n * a problem with the unit code or unit name\n */\n addUnit(theUnit) {\n\n let uName = theUnit['name_'] ;\n if (uName) {\n this.addUnitName(theUnit);\n }\n\n this.addUnitCode(theUnit);\n this.addUnitString(theUnit);\n\n try {\n if (theUnit['dim_'].getProperty('dimVec_'))\n this.addUnitDimension(theUnit);\n }\n catch(err){\n // do nothing - throws error if the property is null\n // and that's OK here.\n }\n\n if (theUnit.isBase_) {\n const dimVec = theUnit.dim_.dimVec_;\n let nonZeroIndex;\n for (let i=0, len=dimVec.length; nonZeroIndex==undefined && i<len; ++i) {\n if (dimVec[i] != 0)\n nonZeroIndex = i;\n }\n this.dimVecIndexToBaseUnit_[nonZeroIndex] = theUnit.csCode_;\n }\n } // end addUnit\n\n\n /**\n * Adds a Unit object to the unitNames_ table. More than one unit\n * can have the same name, e.g., the two units with the name \"second\",\n * where the code for one of them is 's' and the code for the other is\n * \"'\". Because of this, an array of unit objects is stored for the\n * name. In most cases it will be an array of one object, but this\n * clarifies that there may be more than one.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws an error if the unit has no name\n */\n addUnitName(theUnit) {\n\n let uName = theUnit['name_'];\n\n if (uName) {\n if (this.unitNames_[uName])\n this.unitNames_[uName].push(theUnit);\n else\n this.unitNames_[uName] = [theUnit];\n }\n else\n throw(new Error('UnitTables.addUnitName called for a unit with no name. ' +\n `Unit code = ${theUnit['csCode_']}.`));\n\n } // end addUnitName\n\n\n /**\n * Adds a Unit object to the unitCodes_, unitUcCodes_, unitLcCodes_ and\n * codeOrder_ tables. This also sets the mass dimension index when the\n * base mass unit (gram) is read.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws an error if the unitCodes_ table already contains a unit with\n * the code\n */\n addUnitCode(theUnit) {\n\n let uCode = theUnit['csCode_'];\n if (uCode) {\n\n if (this.unitCodes_[uCode])\n throw(new Error(`UnitTables.addUnitCode called, already contains entry for ` +\n `unit with code = ${uCode}`));\n else {\n this.unitCodes_[uCode] = theUnit;\n this.codeOrder_.push(uCode);\n if (uCode == 'g') {\n let dimVec = theUnit.dim_.dimVec_;\n let d = 0;\n for (; d < dimVec.length && dimVec[d] < 1; d++) ;\n this.massDimIndex_ = d;\n }\n }\n }\n else\n throw(new Error('UnitTables.addUnitCode called for unit that has ' +\n 'no code.')) ;\n\n } // end addUnitCode\n\n\n /**\n * Adds a unit object to the unitStrings_ table. More than one unit\n * can have the same string, so an array of unit objects is stored\n * for the string. The unit string is the string that creates a non-base\n * unit, e.g., a Newton has a unit code of N, a name of Newton, and a\n * unitString of kg.m/s2.\n *\n * If the unit has no string, nothing is stored and no error is reported.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n */\n addUnitString(theUnit) {\n\n let uString = null;\n if (Ucum.caseSensitive_ == true)\n uString = theUnit['csUnitString_'];\n else\n uString = theUnit['ciUnitString_'];\n\n if (uString) {\n let uEntry = {mag: theUnit['baseFactorStr_'], unit: theUnit};\n if (this.unitStrings_[uString])\n this.unitStrings_[uString].push(uEntry);\n else\n this.unitStrings_[uString] = [uEntry];\n }\n } // end addUnitString\n\n\n /**\n * Adds a Unit object to the unitDimensions_ table. More than one unit\n * can have the same dimension (commensurable units have the same dimension).\n * Because of this, an array of unit objects is stored for the\n * dimension.\n *\n * @param theUnit the unit to be added\n * @returns nothing\n * @throws an error if the unit has no dimension\n */\n addUnitDimension(theUnit) {\n\n let uDim = theUnit['dim_'].getProperty('dimVec_');\n\n if (uDim) {\n if (this.unitDimensions_[uDim])\n this.unitDimensions_[uDim].push(theUnit);\n else\n this.unitDimensions_[uDim] = [theUnit];\n }\n else\n throw(new Error('UnitTables.addUnitDimension called for a unit with no dimension. ' +\n `Unit code = ${theUnit['csCode_']}.`));\n\n } // end addUnitDimension\n\n\n /**\n * Builds the unitSynonyms_ table. This is called the first time the\n * getUnitsBySynonym method is called. The table/hash contains each word\n * (once) from each synonym as well as each word from each unit name.\n *\n * Hash keys are the words. Hash values are an array of unit codes for\n * each unit that has that word in its synonyms or name.\n *\n * @returns nothing\n */\n buildUnitSynonyms() {\n\n for (let code in this.unitCodes_) {\n let theUnit = this.unitCodes_[code];\n let uSyns = theUnit.synonyms_ ;\n\n // If the current unit has synonyms, process each synonym (often multiples)\n if (uSyns) {\n let synsAry = uSyns.split(';');\n if (synsAry[0] !== '') {\n let aLen = synsAry.length;\n for (let a = 0; a < aLen; a++) {\n let theSyn = synsAry[a].trim();\n\n // call addSynonymCodes to process each word in the\n // synonym, e.g., \"British fluid ounces\"\n this.addSynonymCodes(code, theSyn) ;\n } // end do for each synonym\n } // end if the current unit has a non-null synonym attribute\n } // end if the unit has any synonyms\n\n // Now call addSynonymCodes to process each word in the unit's name\n this.addSynonymCodes(code, theUnit.name_) ;\n } // end do for each unit\n } // end buildUnitSynonyms\n\n\n /**\n * Adds unit code entries to the synonyms table for a string containing\n * one or more words to be considered as synonyms.\n *\n * @param theCode the unit code to be connected to the synonyms\n * @param theSynonyms a string containing one or more words to be\n * considered synonyms (and thus to be added to the unitSynonyms hash).\n */\n addSynonymCodes(theCode, theSynonyms) {\n\n let words = theSynonyms.split(' ');\n let wLen = words.length;\n\n for (let w = 0; w < wLen; w++) {\n let word = words[w];\n\n // if there is already a synonyms entry for the word,\n // get the array of unit codes currently assigned to\n // the word and add the code for the current word to\n // the synonyms array if it's not already there.\n if (this.unitSynonyms_[word]) {\n let synCodes = this.unitSynonyms_[word];\n if (synCodes.indexOf(theCode) === -1) {\n this.unitSynonyms_[word].push(theCode);\n }\n }\n // else there are no synonyms entry for the word. Create a\n // synonyms array for the word, setting it to contain the unit code.\n else {\n this.unitSynonyms_[word] = [theCode];\n }\n } // end do for each word in the synonyms being processed\n\n } // end addSynonymCodes\n\n\n /**\n * Returns a unit object with a case-sensitive code matching the\n * uCode parameter, or null if no unit is found with that code.\n *\n * @param uCode the code of the unit to be returned\n * @returns the unit object or null if it is not found\n */\n getUnitByCode(uCode) {\n let retUnit = null ;\n if (uCode) {\n retUnit = this.unitCodes_[uCode];\n }\n return retUnit ;\n }\n\n\n /**\n * Returns a array of unit objects based on the unit's name. Usually this\n * will be an array of one, but there may be more, since unit names are\n * not necessarily unique.\n *\n * @param uName the name of the unit to be returned. If more than one\n * unit has the same name and you only want one specific unit, append the\n * csCode of the unit you want to the end of the name, separated by the\n * Ucum.codeSep_ value, e.g., inch - [in_i] vs. inch - [in_us].\n * @returns null if no unit was found for the specified name OR an array of\n * unit objects with the specified name. Normally this will be an array\n * of one object.\n * @throws an error if no name is provided to search on\n */\n getUnitByName(uName) {\n\n if (uName === null || uName === undefined) {\n throw (new Error('Unable to find unit by name because no name was provided.'));\n }\n let sepPos = uName.indexOf(Ucum.codeSep_);\n let uCode = null;\n if (sepPos >= 1) {\n uCode = uName.substr(sepPos + Ucum.codeSep_.length);\n uName = uName.substr(0, sepPos);\n }\n let retUnits = this.unitNames_[uName] ;\n if (retUnits) {\n let uLen = retUnits.length ;\n\n if (uCode && uLen > 1) {\n let i = 0;\n for (; retUnits[i].csCode_ !== uCode && i < uLen; i++);\n if (i < uLen)\n retUnits = [retUnits[i]];\n else {\n retUnits = null;\n }\n } // end if we need to find both a name and a code\n } // end if we got an array of units\n return retUnits ;\n\n } // end getUnitByName\n\n\n /**\n * Returns an array of unit objects with the specified unit string.\n * The array may contain one or more unit reference objects.\n * Or none, if no units have a matching unit string (which is not\n * considered an error)\n *\n * @param name the name of the unit to be returned\n * @returns the array of unit references or null if none were found\n */\n getUnitByString(uString) {\n let retAry = null ;\n if (uString) {\n retAry = this.unitStrings_[uString] ;\n if (retAry === undefined)\n retAry = null;\n }\n return retAry ;\n }\n\n\n /**\n * Returns a array of unit objects based on the unit's dimension vector.\n *\n * @param uName the dimension vector of the units to be returned.\n *\n * @returns null if no unit was found for the specified vector OR an array of\n * one or more unit objects with the specified vector.\n * @throws an error if no vector is provided to search on\n * logs an error to the console if no unit is found\n */\n getUnitsByDimension(uDim) {\n\n let unitsArray = null ;\n if (uDim === null || uDim === undefined) {\n throw (new Error('Unable to find unit by because no dimension ' +\n 'vector was provided.'));\n }\n\n unitsArray = this.unitDimensions_[uDim] ;\n if (unitsArray === undefined || unitsArray === null) {\n console.log(`Unable to find unit with dimension = ${uDim}`);\n }\n\n return unitsArray ;\n\n } // end getUnitsByDimension\n\n\n /**\n * Returns a array of unit objects that include the specified synonym.\n *\n * @param uSyn the synonym of the units to be returned.\n *\n * @returns an object with two of the following three elements:\n * 'status' will be error, failed or succeeded\n * 'msg' will be included for returns with status = error or failed and\n * will explain why the request did not return any units\n * 'units' any array of unit objects with the specified synonym will be\n * returned for requests with status = succeeded\n */\n getUnitBySynonym(uSyn) {\n\n let retObj = {} ;\n let unitsArray = [];\n\n try {\n if (uSyn === null || uSyn === undefined) {\n retObj['status'] = 'error' ;\n throw (new Error('Unable to find unit by synonym because no synonym ' +\n 'was provided.'));\n }\n // If this is the first request for a unit by synonym, build the hash map\n if (Object.keys(this.unitSynonyms_).length === 0) {\n this.buildUnitSynonyms();\n }\n let foundCodes = [];\n foundCodes = this.unitSynonyms_[uSyn];\n if (foundCodes) {\n retObj['status'] = 'succeeded';\n let fLen = foundCodes.length;\n for (let f = 0; f < fLen; f++) {\n unitsArray.push(this.unitCodes_[foundCodes[f]]);\n }\n retObj['units'] = unitsArray ;\n }\n if (unitsArray.length === 0) {\n retObj['status'] = 'failed' ;\n retObj['msg'] = `Unable to find any units with synonym = ${uSyn}`;\n }\n }\n catch(err) {\n retObj['msg'] = err.message ;\n }\n return retObj ;\n } // end getUnitBySynonym\n\n\n /**\n * Gets a list of all unit names in the Unit tables\n *\n * @returns an array of the unit names\n */\n getAllUnitNames() {\n return Object.keys(this.unitNames_);\n } // end getAllUnitNames\n\n\n /**\n * Gets a list of all unit names in the tables. Where more than one\n * unit has the same name, the unit code, in parentheses, is appended\n * to the end of the name.\n *\n * @returns {Array}\n */\n getUnitNamesList() {\n let nameList = [];\n let codes = Object.keys(this.unitCodes_);\n codes.sort(this.compareCodes) ;\n let uLen = codes.length;\n for (let i = 0; i < uLen; i++) {\n nameList[i] = codes[i] + Ucum.codeSep_ + this.unitCodes_[codes[i]].name_\n } // end do for each code\n return nameList ;\n }\n\n\n /*\n * Returns the mass dimension index\n * @returns this.massDimIndex_\n */\n getMassDimensionIndex() {\n return this.massDimIndex_ ;\n }\n\n /**\n * This provides a sort function for unit codes so that sorting ignores\n * square brackets and case.\n *\n * @param a first value\n * @param b second value\n * @returns -1 if a is should fall before b; otherwise 1.\n */\n compareCodes(a, b) {\n a = a.replace(/[\\[\\]]/g, '');\n a = a.toLowerCase();\n b = b.replace(/[\\[\\]]/g, '');\n b = b.toLowerCase();\n return (a < b) ? -1 : 1 ;\n }\n\n\n /**\n * Gets a list of all unit codes in the Unit tables\n *\n * @returns an array of the unit names\n */\n getAllUnitCodes() {\n return Object.keys(this.unitCodes_);\n } // end getAllUnitNames\n\n\n /**\n * This is used to get all unit objects. Currently it is used\n * to get the objects to write to the json ucum definitions file\n * that is used to provide prefix and unit definition objects for\n * conversions and validations.\n *\n * @returns an array containing all unit objects, ordered by definition\n * order\n */\n allUnitsByDef() {\n\n let unitsList = [];\n let uLen = this.codeOrder_.length ;\n for (let u = 0; u < uLen; u++) {\n unitsList.push(this.getUnitByCode(this.codeOrder_[u]));\n }\n return unitsList ;\n } // end allUnitsByDef\n\n\n /**\n * This is used to get all unit objects, ordered by unit name. Currently it\n * is used to create a csv list of all units.\n * @param sep separator character (or string) to be used to separate each\n * column in the output. Optional, defaults to '|' if not specified.\n * (Used to use ; but the synonyms use that extensively). Don't use a\n * comma or any other punctuation found in the output data.\n * @returns a buffer containing all unit objects, ordered by name\n * order\n */\n allUnitsByName(cols, sep) {\n if (sep === undefined || sep === null)\n sep = '|';\n let unitBuff = '';\n let unitsList = this.getAllUnitNames();\n let uLen = unitsList.length;\n let cLen = cols.length;\n for (let i = 0; i < uLen; i++) {\n let nameRecs = this.getUnitByName(unitsList[i]);\n for (let u = 0; u < nameRecs.length; u++) {\n let rec = nameRecs[u];\n for (let c = 0; c < cLen; c++) {\n if (c > 0)\n unitBuff += sep;\n if (cols[c] === 'dim_') {\n if (rec.dim_ !== null && rec.dim_ !== undefined &&\n rec.dim_.dimVec_ instanceof Array)\n unitBuff += '[' + rec.dim_.dimVec_.join(',') + ']';\n else\n unitBuff += '';\n }\n else {\n let cbuf = rec[cols[c]];\n if (typeof cbuf === 'string')\n unitBuff += cbuf.replace(/[\\n\\r]/g, ' ');\n else\n unitBuff += cbuf ;\n }\n } // end do for each column requested\n unitBuff += '\\r\\n';\n } // end do for each unit in the unit names array\n }\n return unitBuff ;\n } // end allUnitsByName\n\n\n /**\n * This creates a list of all units in the tables. It uses the byCode\n * table, and uses the codeOrder_ array to determine the order in which\n * the units are listed.\n *\n * @param doLong boolean indicating how much to output. If true, all data\n * from the unit objects is included. If false, only a few major values\n * are included.\n * @param sep separator character (or string) to be used to separate each\n * column in the output. Optional, defaults to '|' if not specified.\n * (Used to use ; but the synonyms use that extensively).\n * @returns {string} buffer containing all the listings\n */\n printUnits(doLong, sep) {\n if (doLong === undefined)\n doLong = false ;\n if (sep === undefined)\n sep = '|';\n let codeList = '';\n let uLen = this.codeOrder_.length ;\n let unitString = 'csCode' + sep ;\n if (doLong) {\n unitString += 'ciCode' + sep ;\n }\n unitString += 'name' + sep ;\n if (doLong)\n unitString += 'isBase' + sep ;\n unitString += 'magnitude' + sep + 'dimension' + sep + 'from unit(s)' + sep +\n 'value' + sep + 'function' + sep ;\n if (doLong)\n unitString += 'property' + sep + 'printSymbol' + sep + 'synonyms' + sep +\n 'source' + sep + 'class' + sep + 'isMetric' + sep +\n 'variable' + sep + 'isSpecial' + sep + 'isAbitrary' + sep ;\n unitString += 'comment';\n codeList = unitString + '\\n' ;\n\n for (let u = 0; u < uLen; u++) {\n let curUnit = this.getUnitByCode(this.codeOrder_[u]);\n unitString = this.codeOrder_[u] + sep ;\n if (doLong) {\n unitString += curUnit.getProperty('ciCode_') + sep ;\n }\n unitString += curUnit.getProperty('name_') + sep ;\n if (doLong) {\n if (curUnit.getProperty('isBase_'))\n unitString += 'true' + sep ;\n else\n unitString += 'false' + sep ;\n }\n unitString += curUnit.getProperty('magnitude_') + sep;\n let curDim = curUnit.getProperty('dim_');\n if (curDim) {\n unitString += curDim.dimVec_ + sep ;\n }\n else {\n unitString += 'null' + sep;\n }\n if (curUnit.csUnitString_)\n unitString += curUnit.csUnitString_ + sep + curUnit.baseFactor_ + sep ;\n else\n unitString += 'null' + sep + 'null' + sep;\n\n if (curUnit.cnv_)\n unitString += curUnit.cnv_ + sep ;\n else\n unitString += 'null' + sep ;\n\n if (doLong) {\n unitString += curUnit.getProperty('property_') + sep +\n curUnit.getProperty('printSymbol_') + sep +\n curUnit.getProperty('synonyms_') + sep +\n curUnit.getProperty('source_') + sep +\n curUnit.getProperty('class_') + sep +\n curUnit.getProperty('isMetric_') + sep +\n curUnit.getProperty('variable_') + sep +\n curUnit.getProperty('isSpecial_') + sep +\n curUnit.getProperty('isArbitrary_') + sep ;\n }\n if (curUnit.defError_)\n unitString += 'problem parsing this one, deferred to later.' ;\n codeList += unitString + '\\n' ;\n }\n return codeList ;\n }\n\n} // end UnitTablesFactory\n\n\n// Create a singleton instance and (to preserve the existing API) an object that\n// provides that instance via getInstance().\nvar unitTablesInstance = new UnitTablesFactory();\nexport const UnitTables = {\n getInstance: function() {\n return unitTablesInstance;\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAIA,IAAI,GAAGC,OAAO,CAAC,aAAa,CAAC,CAACD,IAAI;AAEtC,MAAME,iBAAiB,CAAC;EAEtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EAAG;IAEZ;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,UAAU,GAAG,CAAC,CAAC;;IAEpB;AACJ;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,UAAU,GAAG,CAAC,CAAC;;IAEpB;AACJ;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,UAAU,GAAG,EAAE;;IAEpB;AACJ;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,YAAY,GAAG,CAAC,CAAC;;IAEtB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,eAAe,GAAG,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