@lhncbc/ucum-lhc 7.1.8 → 7.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lhncbc/ucum-lhc",
3
- "version": "7.1.8",
3
+ "version": "7.1.9",
4
4
  "description": "Implements Unified Code for Units of Measure (UCUM) functions in a javascript library",
5
5
  "main": "source-cjs/ucumPkg.js",
6
6
  "homepage": "https://lhncbc.github.io/ucum-lhc/",
@@ -166,7 +166,7 @@ export class Dimension {
166
166
  * @throws an exception if dim2 is not a Dimension object
167
167
  **/
168
168
  add(dim2) {
169
- if (!dim2 instanceof Dimension) {
169
+ if (!(dim2 instanceof Dimension)) {
170
170
  throw(new Error(`Dimension.add called with an invalid parameter - ` +
171
171
  `${typeof dim2} instead of a Dimension object`));
172
172
  }
@@ -188,7 +188,7 @@ export class Dimension {
188
188
  * @throws an exception if dim2 is not a Dimension object
189
189
  **/
190
190
  sub(dim2) {
191
- if (!dim2 instanceof Dimension) {
191
+ if (!(dim2 instanceof Dimension)) {
192
192
  throw(new Error(`Dimension.sub called with an invalid parameter - ` +
193
193
  `${typeof dim2} instead of a Dimension object`));
194
194
  }
@@ -221,14 +221,14 @@ export class Dimension {
221
221
  * when a unit is raised to a power. This object's vector is changed unless
222
222
  * the vector is null, in which case it stays that way.
223
223
  *
224
- * @param s the scalar to use
224
+ * @param s the integer scalar to use
225
225
  * @return this object
226
- * @throws an exception if s is not a number
226
+ * @throws an exception if s is not an integer
227
227
  */
228
228
  mul(s) {
229
229
  if (!isInteger(s)) {
230
- throw(new Error(`Dimension.sub called with an invalid parameter - ` +
231
- `${typeof dim2} instead of a number`));
230
+ throw(new Error(`Dimension.mul called with an invalid parameter - ` +
231
+ `${typeof s} instead of an integer`));
232
232
  }
233
233
  if (this.dimVec_) {
234
234
  for (let i = 0; i < UC.Ucum.dimLen_; i++)
@@ -249,7 +249,7 @@ export class Dimension {
249
249
  * @throws an exception if dim2 is not a Dimension object
250
250
  */
251
251
  equals(dim2) {
252
- if (!dim2 instanceof Dimension) {
252
+ if (!(dim2 instanceof Dimension)) {
253
253
  throw(new Error(`Dimension.equals called with an invalid parameter - ` +
254
254
  `${typeof dim2} instead of a Dimension object`));
255
255
  }
@@ -280,7 +280,7 @@ export class Dimension {
280
280
  */
281
281
  assignDim(dim2) {
282
282
 
283
- if (!dim2 instanceof Dimension) {
283
+ if (!(dim2 instanceof Dimension)) {
284
284
  throw(new Error(`Dimension.assignDim called with an invalid parameter - ` +
285
285
  `${typeof dim2} instead of a Dimension object`));
286
286
  }
package/source/unit.js CHANGED
@@ -243,7 +243,7 @@ export class Unit {
243
243
  */
244
244
  assignVals(vals) {
245
245
  for (let key in vals) {
246
- let uKey = !(key.charAt(key.length - 1)) === '_' ? key + '_' : key ;
246
+ let uKey = key.charAt(key.length - 1) !== '_' ? key + '_' : key ;
247
247
  if (this.hasOwnProperty(uKey))
248
248
  this[uKey] = vals[key];
249
249
  else
@@ -147,7 +147,7 @@ class Dimension {
147
147
  * @throws an exception if dim2 is not a Dimension object
148
148
  **/
149
149
  add(dim2) {
150
- if (!dim2 instanceof Dimension) {
150
+ if (!(dim2 instanceof Dimension)) {
151
151
  throw new Error(`Dimension.add called with an invalid parameter - ` + `${typeof dim2} instead of a Dimension object`);
152
152
  }
153
153
  if (this.dimVec_ && dim2.dimVec_) {
@@ -166,7 +166,7 @@ class Dimension {
166
166
  * @throws an exception if dim2 is not a Dimension object
167
167
  **/
168
168
  sub(dim2) {
169
- if (!dim2 instanceof Dimension) {
169
+ if (!(dim2 instanceof Dimension)) {
170
170
  throw new Error(`Dimension.sub called with an invalid parameter - ` + `${typeof dim2} instead of a Dimension object`);
171
171
  }
172
172
  if (this.dimVec_ && dim2.dimVec_) {
@@ -194,13 +194,13 @@ class Dimension {
194
194
  * when a unit is raised to a power. This object's vector is changed unless
195
195
  * the vector is null, in which case it stays that way.
196
196
  *
197
- * @param s the scalar to use
197
+ * @param s the integer scalar to use
198
198
  * @return this object
199
- * @throws an exception if s is not a number
199
+ * @throws an exception if s is not an integer
200
200
  */
201
201
  mul(s) {
202
202
  if (!isInteger(s)) {
203
- throw new Error(`Dimension.sub called with an invalid parameter - ` + `${typeof dim2} instead of a number`);
203
+ throw new Error(`Dimension.mul called with an invalid parameter - ` + `${typeof s} instead of an integer`);
204
204
  }
205
205
  if (this.dimVec_) {
206
206
  for (let i = 0; i < UC.Ucum.dimLen_; i++) this.dimVec_[i] *= s;
@@ -219,7 +219,7 @@ class Dimension {
219
219
  * @throws an exception if dim2 is not a Dimension object
220
220
  */
221
221
  equals(dim2) {
222
- if (!dim2 instanceof Dimension) {
222
+ if (!(dim2 instanceof Dimension)) {
223
223
  throw new Error(`Dimension.equals called with an invalid parameter - ` + `${typeof dim2} instead of a Dimension object`);
224
224
  }
225
225
  let isEqual = true;
@@ -245,7 +245,7 @@ class Dimension {
245
245
  * @throws an exception if dim2 is not a Dimension object
246
246
  */
247
247
  assignDim(dim2) {
248
- if (!dim2 instanceof Dimension) {
248
+ if (!(dim2 instanceof Dimension)) {
249
249
  throw new Error(`Dimension.assignDim called with an invalid parameter - ` + `${typeof dim2} instead of a Dimension object`);
250
250
  }
251
251
  if (dim2.dimVec_ === null) this.dimVec_ = null;else {
@@ -1 +1 @@
1
- {"version":3,"file":"dimension.js","names":["UC","require","isInteger","Dimension","constructor","dimSetting","Ucum","dimLen_","Error","undefined","assignZero","Array","length","JSON","stringify","dimVec_","d","push","setElementAt","indexPos","value","getElementAt","ret","getProperty","propertyName","uProp","charAt","toString","join","add","dim2","i","sub","minus","mul","s","equals","isEqual","dimVec2","assignDim","isZero","allZero","isNull","clone","that","exports"],"sources":["../source/dimension.js"],"sourcesContent":["/**\n * This class implements an object containing the vector of exponents for\n * a unit and its operations for addition, subtraction, and multiplication\n * with a scalar.\n *\n * This object should exist for each unit that can be expressed as a\n * vector of numbers. This excludes arbitrary units, e.g., (10*23), and\n * units that are not numbers but are an expression based solely on numbers,\n * e.g., mol (mole) which is based on 10*23.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n */\nvar UC = require('./config.js');\nvar isInteger = require(\"is-integer\");\nexport class Dimension {\n\n /**\n * Constructor.\n *\n * @param dimSetting an optional parameter that may be:\n * null, which means that the dimVec_ attribute for this object will be null; or\n * an array, which must be the length defined by Ucum.dimLen_, and\n * whose contents will be copied to this new object's vector; or\n * an integer, which must be between 0 and 1 less than the vector length\n * defined by Ucum.dimLen_. This new object's vector will be\n * initialized to zero for all elements except the one whose index\n * matches the number passed in. That element will be set to one.\n\n * @throws an error if the dimSetting parameter does not meet the types\n * listed above.\n * An error will also be thrown if Ucum.dimLen_ has not been set yet,\n * i.e., is still zero. Currently that won't happen, because the\n * value is set in the config.js file. But further down the road\n * the setting will come from a definitions input file, so we check\n * here anyway.\n *\n */\n constructor(dimSetting) {\n\n if (UC.Ucum.dimLen_ === 0) {\n throw(new Error('Dimension.setDimensionLen must be called before ' +\n 'Dimension constructor'));\n }\n if (dimSetting === undefined || dimSetting === null) {\n this.assignZero() ;\n }\n else if (dimSetting instanceof Array) {\n if (dimSetting.length !== UC.Ucum.dimLen_) {\n throw(new Error('Parameter error, incorrect length of vector passed to ' +\n `Dimension constructor, vector = ${JSON.stringify(dimSetting)}`));\n }\n this.dimVec_ = [];\n for (let d = 0; d < UC.Ucum.dimLen_; d++)\n this.dimVec_.push(dimSetting[d]);\n }\n\n // In es6 this should be Number.isInteger(dimSetting). But Babel\n // doesn't transpile that correctly, so we need to use the isInteger\n // module. :0\n else if (isInteger(dimSetting)) {\n if (dimSetting < 0 || dimSetting >= UC.Ucum.dimLen_) {\n throw(new Error('Parameter error, invalid element number specified for ' +\n 'Dimension constructor'));\n }\n this.assignZero() ;\n this.dimVec_[dimSetting] = 1;\n }\n } // end constructor\n\n\n /**\n * Sets the element at the specified position to a specified value. The\n * default value is 1. If the dimension vector is null when this is called\n * a zero-filled vector is created and then the indicated position is set.\n *\n * @param indexPos the index of the element to be set\n * @param value the value to assign to the specified element; optional,\n * default value is 1\n * @throws an exception if the specified position is invalid, i.e., not a\n * number or is less than 0 or greater than Ucum.dimLen_\n **/\n setElementAt(indexPos, value) {\n\n if (!isInteger(indexPos) ||\n indexPos < 0 || indexPos >= UC.Ucum.dimLen_) {\n throw(new Error(`Dimension.setElementAt called with an invalid index ` +\n `position (${indexPos})`));\n }\n\n if (!this.dimVec_) {\n this.assignZero();\n }\n if (value === undefined || value === null)\n value = 1 ;\n\n this.dimVec_[indexPos] = value;\n }\n\n\n /**\n * Gets the value of the element at the specified position\n *\n * @param indexPos the index of the element whose value is to be returned\n * @return the value of the element at indexPos, or null if the dimension\n * vector is null\n * @throws an exception if the specified position is invalid, i.e., not a\n * number or is less than 0 or greater than Ucum.dimLen_\n **/\n getElementAt(indexPos) {\n if (!isInteger(indexPos) ||\n indexPos < 0 || indexPos >= UC.Ucum.dimLen_) {\n throw(new Error(`Dimension.getElementAt called with an invalid index ` +\n `position (${indexPos})`));\n }\n let ret = null;\n if (this.dimVec_)\n ret = this.dimVec_[indexPos];\n return ret;\n }\n\n\n /**\n * This returns the value of the property named by the parameter\n * passed in. Although we currently only have one property, dimVec_,\n * that this will get, it's possible that we'll have additional\n * properties. If we don't this could just be replaced by a\n * getVector function.\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 Dimension\n * @throws an error if the property is not found for this Dimension\n */\n getProperty(propertyName) {\n let uProp = propertyName.charAt(propertyName.length - 1) === '_' ? propertyName : propertyName + '_';\n\n return this[uProp] ;\n\n } // end getProperty\n\n\n /**\n * Return a string that represents the dimension vector. Returns null if\n * the dimension vector is null.\n *\n * @return the string that represents the dimension vector. The\n * values are enclosed in square brackets, each separated\n * by a comma and a space\n **/\n toString() {\n let ret = null ;\n if (this.dimVec_)\n ret = '[' + this.dimVec_.join(', ') + ']';\n return ret ;\n }\n\n\n /**\n * Adds the vector of the dimension object passed in to this\n * dimension object's vector. This object's vector is changed.\n * If either dimension vector is null, no changes are made to this object.\n *\n *\n * @param dim2 the dimension whose vector is to be added to this one\n * @return this object\n * @throws an exception if dim2 is not a Dimension object\n **/\n add(dim2) {\n if (!dim2 instanceof Dimension) {\n throw(new Error(`Dimension.add called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n if (this.dimVec_ && dim2.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] += dim2.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Subtracts the vector of the dimension object passed in from this\n * dimension object's vector. This object's vector is changed.\n * If either dimension vector is null, no changes are made to this object.\n *\n * @param dim2 the dimension whose vector is to be subtracted from this one\n * @return this object\n * @throws an exception if dim2 is not a Dimension object\n **/\n sub(dim2) {\n if (!dim2 instanceof Dimension) {\n throw(new Error(`Dimension.sub called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n if (this.dimVec_ && dim2.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] -= dim2.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Inverts this dimension object's vector (by multiplying each element\n * by negative 1). This object's vector is changed - unless it is null,\n * in which case it stays that way.\n *\n * @return this object\n **/\n minus() {\n if (this.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] = -this.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Multiplies this dimension object's vector with a scalar. This is used\n * when a unit is raised to a power. This object's vector is changed unless\n * the vector is null, in which case it stays that way.\n *\n * @param s the scalar to use\n * @return this object\n * @throws an exception if s is not a number\n */\n mul(s) {\n if (!isInteger(s)) {\n throw(new Error(`Dimension.sub called with an invalid parameter - ` +\n `${typeof dim2} instead of a number`));\n }\n if (this.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] *= s;\n }\n return this;\n }\n\n\n /**\n * Tests for equality of this dimension object's vector and that of\n * the dimension object passed in. If the dimension vector for one of\n * the objects is null, the dimension vector for the other object must\n * also be null for the two to be equal. (I know - duh. still)\n *\n * @param dim2 the dimension object whose vector is to be compared to this one\n * @return true if the two vectors are equal; false otherwise.\n * @throws an exception if dim2 is not a Dimension object\n */\n equals(dim2) {\n if (!dim2 instanceof Dimension) {\n throw(new Error(`Dimension.equals called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n let isEqual = true ;\n let dimVec2 = dim2.dimVec_;\n if (this.dimVec_ && dimVec2) {\n for (let i = 0; isEqual && i < UC.Ucum.dimLen_; i++)\n isEqual = (this.dimVec_[i] === dimVec2[i]);\n }\n else {\n isEqual = (this.dimVec_ === null && dimVec2 === null);\n }\n return isEqual;\n }\n\n\n /**\n * Assigns the contents of the vector belonging to the dimension object\n * passed in to this dimension's vector. If this dimension vector is null\n * and the other is not, this one will get the contents of the other. If\n * this dimension vector is not null but the one passed in is null, this\n * one will be set to null.\n *\n * @param dim2 the dimension object with the vector whose contents are\n * to be assigned to this dimension's vector\n * @return this object (not sure why)\n * @throws an exception if dim2 is not a Dimension object\n */\n assignDim(dim2) {\n\n if (!dim2 instanceof Dimension) {\n throw(new Error(`Dimension.assignDim called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n if (dim2.dimVec_ === null)\n this.dimVec_ = null;\n else {\n if (this.dimVec_ === null) {\n this.dimVec_ = [] ;\n }\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] = dim2.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Sets all elements of this dimension object's vector to zero.\n * If this object's vector is null, it is created as a zero-filled vector.\n *\n * @return this object (not sure why)\n */\n assignZero() {\n if (this.dimVec_ === null || this.dimVec_ === undefined)\n this.dimVec_ = [];\n\n for (let i = 0; i < UC.Ucum.dimLen_; i++) {\n this.dimVec_.push(0);\n }\n return this;\n }\n\n\n /**\n * Tests for a dimension vector set to all zeroes.\n *\n * @return true if exponents (elements) of this dimension's vector are all\n * zero; false otherwise (including if the current vector is null).\n *\n */\n isZero() {\n let allZero = this.dimVec_ !== null ;\n if (this.dimVec_) {\n for (let i = 0; allZero && i < UC.Ucum.dimLen_; i++)\n allZero = this.dimVec_[i] === 0;\n }\n return allZero;\n }\n\n\n /**\n * Tests for a Dimension object with no dimension vector (dimVec_ is null).\n *\n * @return true the dimension vector is null; false if it is not\n *\n */\n isNull() {\n return (this.dimVec_ === null);\n }\n\n\n /**\n * Creates and returns a clone of this Dimension object\n *\n * @return the clone\n */\n clone() {\n let that = new Dimension();\n that.assignDim(this);\n return that;\n }\n\n} // end Dimension class\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,EAAE,GAAGC,OAAO,CAAC,aAAa,CAAC;AAC/B,IAAIC,SAAS,GAAGD,OAAO,CAAC,YAAY,CAAC;AAC9B,MAAME,SAAS,CAAC;EAErB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAEEC,WAAWA,CAACC,UAAU,EAAE;IAEtB,IAAIL,EAAE,CAACM,IAAI,CAACC,OAAO,KAAK,CAAC,EAAE;MACzB,MAAM,IAAIC,KAAK,CAAC,kDAAkD,GAClE,uBAAuB,CAAC;IAC1B;IACA,IAAIH,UAAU,KAAKI,SAAS,IAAIJ,UAAU,KAAK,IAAI,EAAE;MACnD,IAAI,CAACK,UAAU,CAAC,CAAC;IACnB,CAAC,MACI,IAAIL,UAAU,YAAYM,KAAK,EAAE;MACpC,IAAIN,UAAU,CAACO,MAAM,KAAKZ,EAAE,CAACM,IAAI,CAACC,OAAO,EAAE;QACzC,MAAM,IAAIC,KAAK,CAAC,wDAAwD,GACpE,mCAAmCK,IAAI,CAACC,SAAS,CAACT,UAAU,CAAC,EAAE,CAAC;MACtE;MACA,IAAI,CAACU,OAAO,GAAG,EAAE;MACjB,KAAK,I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AAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"dimension.js","names":["UC","require","isInteger","Dimension","constructor","dimSetting","Ucum","dimLen_","Error","undefined","assignZero","Array","length","JSON","stringify","dimVec_","d","push","setElementAt","indexPos","value","getElementAt","ret","getProperty","propertyName","uProp","charAt","toString","join","add","dim2","i","sub","minus","mul","s","equals","isEqual","dimVec2","assignDim","isZero","allZero","isNull","clone","that","exports"],"sources":["../source/dimension.js"],"sourcesContent":["/**\n * This class implements an object containing the vector of exponents for\n * a unit and its operations for addition, subtraction, and multiplication\n * with a scalar.\n *\n * This object should exist for each unit that can be expressed as a\n * vector of numbers. This excludes arbitrary units, e.g., (10*23), and\n * units that are not numbers but are an expression based solely on numbers,\n * e.g., mol (mole) which is based on 10*23.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n */\nvar UC = require('./config.js');\nvar isInteger = require(\"is-integer\");\nexport class Dimension {\n\n /**\n * Constructor.\n *\n * @param dimSetting an optional parameter that may be:\n * null, which means that the dimVec_ attribute for this object will be null; or\n * an array, which must be the length defined by Ucum.dimLen_, and\n * whose contents will be copied to this new object's vector; or\n * an integer, which must be between 0 and 1 less than the vector length\n * defined by Ucum.dimLen_. This new object's vector will be\n * initialized to zero for all elements except the one whose index\n * matches the number passed in. That element will be set to one.\n\n * @throws an error if the dimSetting parameter does not meet the types\n * listed above.\n * An error will also be thrown if Ucum.dimLen_ has not been set yet,\n * i.e., is still zero. Currently that won't happen, because the\n * value is set in the config.js file. But further down the road\n * the setting will come from a definitions input file, so we check\n * here anyway.\n *\n */\n constructor(dimSetting) {\n\n if (UC.Ucum.dimLen_ === 0) {\n throw(new Error('Dimension.setDimensionLen must be called before ' +\n 'Dimension constructor'));\n }\n if (dimSetting === undefined || dimSetting === null) {\n this.assignZero() ;\n }\n else if (dimSetting instanceof Array) {\n if (dimSetting.length !== UC.Ucum.dimLen_) {\n throw(new Error('Parameter error, incorrect length of vector passed to ' +\n `Dimension constructor, vector = ${JSON.stringify(dimSetting)}`));\n }\n this.dimVec_ = [];\n for (let d = 0; d < UC.Ucum.dimLen_; d++)\n this.dimVec_.push(dimSetting[d]);\n }\n\n // In es6 this should be Number.isInteger(dimSetting). But Babel\n // doesn't transpile that correctly, so we need to use the isInteger\n // module. :0\n else if (isInteger(dimSetting)) {\n if (dimSetting < 0 || dimSetting >= UC.Ucum.dimLen_) {\n throw(new Error('Parameter error, invalid element number specified for ' +\n 'Dimension constructor'));\n }\n this.assignZero() ;\n this.dimVec_[dimSetting] = 1;\n }\n } // end constructor\n\n\n /**\n * Sets the element at the specified position to a specified value. The\n * default value is 1. If the dimension vector is null when this is called\n * a zero-filled vector is created and then the indicated position is set.\n *\n * @param indexPos the index of the element to be set\n * @param value the value to assign to the specified element; optional,\n * default value is 1\n * @throws an exception if the specified position is invalid, i.e., not a\n * number or is less than 0 or greater than Ucum.dimLen_\n **/\n setElementAt(indexPos, value) {\n\n if (!isInteger(indexPos) ||\n indexPos < 0 || indexPos >= UC.Ucum.dimLen_) {\n throw(new Error(`Dimension.setElementAt called with an invalid index ` +\n `position (${indexPos})`));\n }\n\n if (!this.dimVec_) {\n this.assignZero();\n }\n if (value === undefined || value === null)\n value = 1 ;\n\n this.dimVec_[indexPos] = value;\n }\n\n\n /**\n * Gets the value of the element at the specified position\n *\n * @param indexPos the index of the element whose value is to be returned\n * @return the value of the element at indexPos, or null if the dimension\n * vector is null\n * @throws an exception if the specified position is invalid, i.e., not a\n * number or is less than 0 or greater than Ucum.dimLen_\n **/\n getElementAt(indexPos) {\n if (!isInteger(indexPos) ||\n indexPos < 0 || indexPos >= UC.Ucum.dimLen_) {\n throw(new Error(`Dimension.getElementAt called with an invalid index ` +\n `position (${indexPos})`));\n }\n let ret = null;\n if (this.dimVec_)\n ret = this.dimVec_[indexPos];\n return ret;\n }\n\n\n /**\n * This returns the value of the property named by the parameter\n * passed in. Although we currently only have one property, dimVec_,\n * that this will get, it's possible that we'll have additional\n * properties. If we don't this could just be replaced by a\n * getVector function.\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 Dimension\n * @throws an error if the property is not found for this Dimension\n */\n getProperty(propertyName) {\n let uProp = propertyName.charAt(propertyName.length - 1) === '_' ? propertyName : propertyName + '_';\n\n return this[uProp] ;\n\n } // end getProperty\n\n\n /**\n * Return a string that represents the dimension vector. Returns null if\n * the dimension vector is null.\n *\n * @return the string that represents the dimension vector. The\n * values are enclosed in square brackets, each separated\n * by a comma and a space\n **/\n toString() {\n let ret = null ;\n if (this.dimVec_)\n ret = '[' + this.dimVec_.join(', ') + ']';\n return ret ;\n }\n\n\n /**\n * Adds the vector of the dimension object passed in to this\n * dimension object's vector. This object's vector is changed.\n * If either dimension vector is null, no changes are made to this object.\n *\n *\n * @param dim2 the dimension whose vector is to be added to this one\n * @return this object\n * @throws an exception if dim2 is not a Dimension object\n **/\n add(dim2) {\n if (!(dim2 instanceof Dimension)) {\n throw(new Error(`Dimension.add called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n if (this.dimVec_ && dim2.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] += dim2.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Subtracts the vector of the dimension object passed in from this\n * dimension object's vector. This object's vector is changed.\n * If either dimension vector is null, no changes are made to this object.\n *\n * @param dim2 the dimension whose vector is to be subtracted from this one\n * @return this object\n * @throws an exception if dim2 is not a Dimension object\n **/\n sub(dim2) {\n if (!(dim2 instanceof Dimension)) {\n throw(new Error(`Dimension.sub called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n if (this.dimVec_ && dim2.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] -= dim2.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Inverts this dimension object's vector (by multiplying each element\n * by negative 1). This object's vector is changed - unless it is null,\n * in which case it stays that way.\n *\n * @return this object\n **/\n minus() {\n if (this.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] = -this.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Multiplies this dimension object's vector with a scalar. This is used\n * when a unit is raised to a power. This object's vector is changed unless\n * the vector is null, in which case it stays that way.\n *\n * @param s the integer scalar to use\n * @return this object\n * @throws an exception if s is not an integer\n */\n mul(s) {\n if (!isInteger(s)) {\n throw(new Error(`Dimension.mul called with an invalid parameter - ` +\n `${typeof s} instead of an integer`));\n }\n if (this.dimVec_) {\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] *= s;\n }\n return this;\n }\n\n\n /**\n * Tests for equality of this dimension object's vector and that of\n * the dimension object passed in. If the dimension vector for one of\n * the objects is null, the dimension vector for the other object must\n * also be null for the two to be equal. (I know - duh. still)\n *\n * @param dim2 the dimension object whose vector is to be compared to this one\n * @return true if the two vectors are equal; false otherwise.\n * @throws an exception if dim2 is not a Dimension object\n */\n equals(dim2) {\n if (!(dim2 instanceof Dimension)) {\n throw(new Error(`Dimension.equals called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n let isEqual = true ;\n let dimVec2 = dim2.dimVec_;\n if (this.dimVec_ && dimVec2) {\n for (let i = 0; isEqual && i < UC.Ucum.dimLen_; i++)\n isEqual = (this.dimVec_[i] === dimVec2[i]);\n }\n else {\n isEqual = (this.dimVec_ === null && dimVec2 === null);\n }\n return isEqual;\n }\n\n\n /**\n * Assigns the contents of the vector belonging to the dimension object\n * passed in to this dimension's vector. If this dimension vector is null\n * and the other is not, this one will get the contents of the other. If\n * this dimension vector is not null but the one passed in is null, this\n * one will be set to null.\n *\n * @param dim2 the dimension object with the vector whose contents are\n * to be assigned to this dimension's vector\n * @return this object (not sure why)\n * @throws an exception if dim2 is not a Dimension object\n */\n assignDim(dim2) {\n\n if (!(dim2 instanceof Dimension)) {\n throw(new Error(`Dimension.assignDim called with an invalid parameter - ` +\n `${typeof dim2} instead of a Dimension object`));\n }\n if (dim2.dimVec_ === null)\n this.dimVec_ = null;\n else {\n if (this.dimVec_ === null) {\n this.dimVec_ = [] ;\n }\n for (let i = 0; i < UC.Ucum.dimLen_; i++)\n this.dimVec_[i] = dim2.dimVec_[i];\n }\n return this;\n }\n\n\n /**\n * Sets all elements of this dimension object's vector to zero.\n * If this object's vector is null, it is created as a zero-filled vector.\n *\n * @return this object (not sure why)\n */\n assignZero() {\n if (this.dimVec_ === null || this.dimVec_ === undefined)\n this.dimVec_ = [];\n\n for (let i = 0; i < UC.Ucum.dimLen_; i++) {\n this.dimVec_.push(0);\n }\n return this;\n }\n\n\n /**\n * Tests for a dimension vector set to all zeroes.\n *\n * @return true if exponents (elements) of this dimension's vector are all\n * zero; false otherwise (including if the current vector is null).\n *\n */\n isZero() {\n let allZero = this.dimVec_ !== null ;\n if (this.dimVec_) {\n for (let i = 0; allZero && i < UC.Ucum.dimLen_; i++)\n allZero = this.dimVec_[i] === 0;\n }\n return allZero;\n }\n\n\n /**\n * Tests for a Dimension object with no dimension vector (dimVec_ is null).\n *\n * @return true the dimension vector is null; false if it is not\n *\n */\n isNull() {\n return (this.dimVec_ === null);\n }\n\n\n /**\n * Creates and returns a clone of this Dimension object\n *\n * @return the clone\n */\n clone() {\n let that = new Dimension();\n that.assignDim(this);\n return that;\n }\n\n} // end Dimension class\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,EAAE,GAAGC,OAAO,CAAC,aAAa,CAAC;AAC/B,IAAIC,SAAS,GAAGD,OAAO,CAAC,YAAY,CAAC;AAC9B,MAAME,SAAS,CAAC;EAErB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAEEC,WAAWA,CAACC,UAAU,EAAE;IAEtB,IAAIL,EAAE,CAACM,IAAI,CAACC,OAAO,KAAK,CAAC,EAAE;MACzB,MAAM,I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AACC,OAAO,EAAEwB,CAAC,EAAE,EACjDU,OAAO,GAAG,IAAI,CAAC1B,OAAO,CAACgB,CAAC,CAAC,KAAK,CAAC;IACnC;IACA,OAAOU,OAAO;EAChB;;EAGA;AACF;AACA;AACA;AACA;AACA;EACEC,MAAMA,CAAA,EAAG;IACP,OAAQ,IAAI,CAAC3B,OAAO,KAAK,IAAI;EAC/B;;EAGA;AACF;AACA;AACA;AACA;EACE4B,KAAKA,CAAA,EAAG;IACN,IAAIC,IAAI,GAAG,IAAIzC,SAAS,CAAC,CAAC;IAC1ByC,IAAI,CAACL,SAAS,CAAC,IAAI,CAAC;IACpB,OAAOK,IAAI;EACb;AAEF,CAAC,CAAC;AAAAC,OAAA,CAAA1C,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -237,7 +237,7 @@ class Unit {
237
237
  */
238
238
  assignVals(vals) {
239
239
  for (let key in vals) {
240
- let uKey = !key.charAt(key.length - 1) === '_' ? key + '_' : key;
240
+ let uKey = key.charAt(key.length - 1) !== '_' ? key + '_' : key;
241
241
  if (this.hasOwnProperty(uKey)) this[uKey] = vals[key];else throw new Error(`Parameter error; ${key} is not a property of a Unit`);
242
242
  }
243
243
  } // end assignVals
@@ -1 +1 @@
1
- {"version":3,"file":"unit.js","names":["_ucumFunctions","_interopRequireDefault","require","intUtils_","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","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","key","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","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 https://ucum.org/ucum specification 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,SAAAE,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,C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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE6J,wBAAwBA,CAACxH,KAAK,EAAE;IAC9B,MAAM+D,CAAC,GAAG,IAAI,CAACxB,cAAc,CAAC,CAAC,CAACyB,qBAAqB,CAAC,CAAC;IACvD,MAAMiD,QAAQ,GAAG,IAAI,CAACtJ,IAAI,CAAC+B,KAAK,CAAC,CAAC;IAClCuH,QAAQ,CAACC,YAAY,CAACnD,CAAC,EAAEkD,QAAQ,CAAC5E,YAAY,CAAC0B,CAAC,CAAC,GAAG,IAAI,CAACzF,cAAc,GACrE,IAAI,CAACD,QAAQ,CAAC;IAChB,MAAM8I,QAAQ,GAAGnH,KAAK,CAACrC,IAAI,CAAC+B,KAAK,CAAC,CAAC;IACnCyH,QAAQ,CAACD,YAAY,CAACnD,CAAC,EAAEoD,QAAQ,CAAC9E,YAAY,CAAC0B,CAAC,CAAC,GAAG/D,KAAK,CAAC1B,cAAc,GACtE0B,KAAK,CAAC3B,QAAQ,CAAC;IACjB,OAAO4I,QAAQ,CAAChH,MAAM,CAACkH,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","ignoreList":[]}
1
+ {"version":3,"file":"unit.js","names":["_ucumFunctions","_interopRequireDefault","require","intUtils_","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","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","key","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","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 https://ucum.org/ucum specification 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,SAAAE,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,E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