@lhncbc/ucum-lhc 7.1.6 → 7.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser-dist/ucum-lhc.min.js +1 -1
- package/browser-dist/ucum-lhc.min.js.map +1 -1
- package/package.json +6 -8
- package/source/unitString.js +165 -99
- package/source-cjs/config.js +1 -2
- package/source-cjs/config.js.map +1 -1
- package/source-cjs/dimension.js.map +1 -1
- package/source-cjs/prefixTables.js +2 -3
- package/source-cjs/prefixTables.js.map +1 -1
- package/source-cjs/ucumFunctions.js +1 -2
- package/source-cjs/ucumFunctions.js.map +1 -1
- package/source-cjs/ucumInternalUtils.js +2 -2
- package/source-cjs/ucumJsonDefs.js +1 -2
- package/source-cjs/ucumJsonDefs.js.map +1 -1
- package/source-cjs/ucumLhcUtils.js.map +1 -1
- package/source-cjs/ucumPkg.js +3 -6
- package/source-cjs/ucumPkg.js.map +1 -1
- package/source-cjs/ucumXmlDocument.js.map +1 -1
- package/source-cjs/unit.js.map +1 -1
- package/source-cjs/unitString.js +150 -92
- package/source-cjs/unitString.js.map +1 -1
- package/source-cjs/unitTables.js +1 -2
- package/source-cjs/unitTables.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lhncbc/ucum-lhc",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.8",
|
|
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/",
|
|
@@ -32,19 +32,16 @@
|
|
|
32
32
|
"@babel/preset-env": "^7.6.2",
|
|
33
33
|
"@babel/register": "^7.6.2",
|
|
34
34
|
"babel-loader": "^8.0.6",
|
|
35
|
-
"babelify": "^10.0.0",
|
|
36
35
|
"bower": "^1.8.8",
|
|
36
|
+
"fast-xml-parser": "^5.5.2",
|
|
37
37
|
"grunt": "^1.5.3",
|
|
38
38
|
"grunt-babel": "^8.0.0",
|
|
39
|
-
"grunt-browserify": "^6.0.0",
|
|
40
39
|
"grunt-cli": "^1.4.3",
|
|
41
40
|
"grunt-contrib-clean": "^1.0.0",
|
|
42
41
|
"grunt-contrib-cssmin": "^3.0.0",
|
|
43
|
-
"grunt-contrib-uglify": "^5.2.2",
|
|
44
|
-
"grunt-extract-sourcemap": "^0.1.19",
|
|
45
42
|
"grunt-mocha-test": "^0.13.2",
|
|
46
43
|
"jit-grunt": "^0.10.0",
|
|
47
|
-
"mocha": "^
|
|
44
|
+
"mocha": "^11.7.5",
|
|
48
45
|
"path": "^0.12.7",
|
|
49
46
|
"semver": "^5.5.1",
|
|
50
47
|
"time-grunt": "^1.4.0",
|
|
@@ -52,8 +49,9 @@
|
|
|
52
49
|
"webpack-cli": "^5.0.1"
|
|
53
50
|
},
|
|
54
51
|
"scripts": {
|
|
55
|
-
"build": "grunt build
|
|
56
|
-
"test": "grunt test"
|
|
52
|
+
"build": "grunt build",
|
|
53
|
+
"test": "grunt test",
|
|
54
|
+
"scan": "rm source.zip; zip -r source source"
|
|
57
55
|
},
|
|
58
56
|
"repository": {
|
|
59
57
|
"type": "git",
|
package/source/unitString.js
CHANGED
|
@@ -1076,40 +1076,6 @@ export class UnitString {
|
|
|
1076
1076
|
retUnit.ciCode_ = retUnit.ciCode_.replace('*', '^');
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
|
-
// If that didn't work, check to see if it should have brackets
|
|
1080
|
-
// around it (uCode = degF when it should be [degF]
|
|
1081
|
-
if (!retUnit) {
|
|
1082
|
-
let addBrackets = '[' + uCode + ']' ;
|
|
1083
|
-
retUnit = this.utabs_.getUnitByCode(addBrackets);
|
|
1084
|
-
if (retUnit) {
|
|
1085
|
-
retUnit = retUnit.clone();
|
|
1086
|
-
origString = origString.replace(uCode, addBrackets);
|
|
1087
|
-
this.retMsg_.push(`${uCode} is not a valid unit expression, but ` +
|
|
1088
|
-
`${addBrackets} is.\n` + this.vcMsgStart_ +
|
|
1089
|
-
`${addBrackets} (${retUnit.name_})${this.vcMsgEnd_}`);
|
|
1090
|
-
} // end if we found the unit after adding brackets
|
|
1091
|
-
} // end trying to add brackets
|
|
1092
|
-
|
|
1093
|
-
// If we didn't find it, try it as a name
|
|
1094
|
-
if (!retUnit) {
|
|
1095
|
-
let retUnitAry = this.utabs_.getUnitByName(uCode);
|
|
1096
|
-
if (retUnitAry && retUnitAry.length > 0) {
|
|
1097
|
-
retUnit = retUnitAry[0].clone();
|
|
1098
|
-
let mString = 'The UCUM code for ' + uCode + ' is ' +
|
|
1099
|
-
retUnit.csCode_ + '.\n' + this.vcMsgStart_ +
|
|
1100
|
-
retUnit.csCode_ + this.vcMsgEnd_;
|
|
1101
|
-
let dupMsg = false;
|
|
1102
|
-
for (let r = 0; r < this.retMsg_.length && !dupMsg; r++)
|
|
1103
|
-
dupMsg = this.retMsg_[r] === mString;
|
|
1104
|
-
if (!dupMsg)
|
|
1105
|
-
this.retMsg_.push(mString);
|
|
1106
|
-
let rStr = new RegExp('(^|[.\/({])(' + uCode + ')($|[.\/)}])');
|
|
1107
|
-
let res = origString.match(rStr);
|
|
1108
|
-
origString = origString.replace(rStr, res[1] + retUnit.csCode_ + res[3]);
|
|
1109
|
-
uCode = retUnit.csCode_;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
1079
|
// If we still don't have a unit, try assuming a modifier (prefix and/or
|
|
1114
1080
|
// exponent) and look for a unit without the modifier
|
|
1115
1081
|
if (!retUnit) {
|
|
@@ -1189,13 +1155,22 @@ export class UnitString {
|
|
|
1189
1155
|
// without the exponent, the unit string without a prefix,
|
|
1190
1156
|
// common errors, etc. That's all we can try).
|
|
1191
1157
|
if (!origUnit) {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1158
|
+
let bracketRet = this._getUnitAfterAddingBrackets(origCode, origString);
|
|
1159
|
+
retUnit = bracketRet[0];
|
|
1160
|
+
origString = bracketRet[1];
|
|
1161
|
+
if (!retUnit) {
|
|
1162
|
+
let nameRet = this._getUnitByName(origCode, origString);
|
|
1163
|
+
retUnit = nameRet[0];
|
|
1164
|
+
origString = nameRet[1];
|
|
1165
|
+
if (!retUnit) {
|
|
1166
|
+
// BUT if the user asked for suggestions, at least look for them
|
|
1167
|
+
if (this.suggestions_) {
|
|
1168
|
+
let suggestStat = this._getSuggestions(origCode);
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
this.retMsg_.push(`${origCode} is not a valid UCUM code.`);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1199
1174
|
}
|
|
1200
1175
|
}
|
|
1201
1176
|
else {
|
|
@@ -1214,72 +1189,81 @@ export class UnitString {
|
|
|
1214
1189
|
// If there is an exponent for the unit, apply it to the dimension
|
|
1215
1190
|
// and magnitude now
|
|
1216
1191
|
if (exp) {
|
|
1217
|
-
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1192
|
+
// Special units cannot be raised to a power
|
|
1193
|
+
if (retUnit.isSpecial_) {
|
|
1194
|
+
this.retMsg_.push(`Special units like ${retUnit.name_} cannot be raised to a power.`);
|
|
1195
|
+
retUnit = null;
|
|
1196
|
+
}
|
|
1197
|
+
else {
|
|
1198
|
+
exp = parseInt(exp);
|
|
1199
|
+
if (theDim)
|
|
1200
|
+
theDim = theDim.mul(exp);
|
|
1201
|
+
retUnit.equivalentExp_ *= exp;
|
|
1202
|
+
retUnit.moleExp_ *= exp;
|
|
1203
|
+
theMag = Math.pow(theMag, exp);
|
|
1204
|
+
retUnit.assignVals({'magnitude_': theMag});
|
|
1205
|
+
|
|
1206
|
+
// If there is also a prefix, apply the exponent to the prefix.
|
|
1207
|
+
if (pfxObj) {
|
|
1208
|
+
// We don't need to consider pfxObj.getExp(), because when
|
|
1209
|
+
// present that is reflected in the pfxVal. However, in some
|
|
1210
|
+
// cases one can avoid floating-point math inaccuracies by using
|
|
1211
|
+
// that exponent instead of relying on pfxVal. For example:
|
|
1212
|
+
// 1e-66 = Math.pow(10, -3*22) = Math.pow(0.001, 22) = 1.0000000000000005e-66
|
|
1213
|
+
// (This is the from the test case of the unit mg% raised to the 22nd power (mg%22).)
|
|
1214
|
+
// This does not help in all cases, but it does help the above
|
|
1215
|
+
// test case (which is in our web API service test code).
|
|
1216
|
+
let pfxExp = pfxObj.getExp();
|
|
1217
|
+
if (pfxExp) {
|
|
1218
|
+
// This is relying on the fact that pfxExp is null when
|
|
1219
|
+
// the prefix base is not 10.
|
|
1220
|
+
pfxVal = Math.pow(10, exp * pfxExp);
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
pfxVal = Math.pow(pfxVal, exp);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
} // end else - prefix and exponent handling for non-special units
|
|
1227
|
+
} // end if there's an exponent
|
|
1228
|
+
|
|
1229
|
+
if (retUnit) {
|
|
1230
|
+
// Now apply the prefix, if there is one, to the conversion
|
|
1231
|
+
// prefix or the magnitude
|
|
1226
1232
|
if (pfxObj) {
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
// cases one can avoid floating-point math inaccuracies by using
|
|
1230
|
-
// that exponent instead of relying on pfxVal. For example:
|
|
1231
|
-
// 1e-66 = Math.pow(10, -3*22) = Math.pow(0.001, 22) = 1.0000000000000005e-66
|
|
1232
|
-
// (This is the from the test case of the unit mg% raised to the 22nd power (mg%22).)
|
|
1233
|
-
// This does not help in all cases, but it does help the above
|
|
1234
|
-
// test case (which is in our web API service test code).
|
|
1235
|
-
let pfxExp = pfxObj.getExp();
|
|
1236
|
-
if (pfxExp) {
|
|
1237
|
-
// This is relying on the fact that pfxExp is null when
|
|
1238
|
-
// the prefix base is not 10.
|
|
1239
|
-
pfxVal = Math.pow(10, exp * pfxExp);
|
|
1233
|
+
if (retUnit.cnv_) {
|
|
1234
|
+
retUnit.assignVals({'cnvPfx_': pfxVal});
|
|
1240
1235
|
}
|
|
1241
1236
|
else {
|
|
1242
|
-
|
|
1237
|
+
theMag *= pfxVal;
|
|
1238
|
+
retUnit.assignVals({'magnitude_': theMag})
|
|
1243
1239
|
}
|
|
1244
1240
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1241
|
+
// if we have a prefix and/or an exponent, add them to the unit
|
|
1242
|
+
// attributes - name, csCode, ciCode and print symbol
|
|
1243
|
+
let theCode = retUnit.csCode_;
|
|
1244
|
+
if (pfxObj) {
|
|
1245
|
+
theName = pfxObj.getName() + theName;
|
|
1246
|
+
theCode = pfxCode + theCode;
|
|
1247
|
+
theCiCode = pfxObj.getCiCode() + theCiCode;
|
|
1248
|
+
thePrintSymbol = pfxObj.getPrintSymbol() + thePrintSymbol;
|
|
1249
|
+
retUnit.assignVals({
|
|
1250
|
+
'name_': theName,
|
|
1251
|
+
'csCode_': theCode,
|
|
1252
|
+
'ciCode_': theCiCode,
|
|
1253
|
+
'printSymbol_': thePrintSymbol
|
|
1254
|
+
});
|
|
1252
1255
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
+
if (exp) {
|
|
1257
|
+
let expStr = exp.toString();
|
|
1258
|
+
const intergerUnitExpSign = isIntegerUnitWithExp && exp > 0 ? '+' : '';
|
|
1259
|
+
retUnit.assignVals({
|
|
1260
|
+
'name_': theName + '<sup>' + expStr + '</sup>',
|
|
1261
|
+
'csCode_': theCode + intergerUnitExpSign + expStr,
|
|
1262
|
+
'ciCode_': theCiCode + intergerUnitExpSign + expStr,
|
|
1263
|
+
'printSymbol_': thePrintSymbol + '<sup>' + expStr + '</sup>'
|
|
1264
|
+
});
|
|
1256
1265
|
}
|
|
1257
1266
|
}
|
|
1258
|
-
// if we have a prefix and/or an exponent, add them to the unit
|
|
1259
|
-
// attributes - name, csCode, ciCode and print symbol
|
|
1260
|
-
let theCode = retUnit.csCode_;
|
|
1261
|
-
if (pfxObj) {
|
|
1262
|
-
theName = pfxObj.getName() + theName;
|
|
1263
|
-
theCode = pfxCode + theCode;
|
|
1264
|
-
theCiCode = pfxObj.getCiCode() + theCiCode;
|
|
1265
|
-
thePrintSymbol = pfxObj.getPrintSymbol() + thePrintSymbol;
|
|
1266
|
-
retUnit.assignVals({
|
|
1267
|
-
'name_': theName,
|
|
1268
|
-
'csCode_': theCode,
|
|
1269
|
-
'ciCode_': theCiCode,
|
|
1270
|
-
'printSymbol_': thePrintSymbol
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
if (exp) {
|
|
1274
|
-
let expStr = exp.toString();
|
|
1275
|
-
const intergerUnitExpSign = isIntegerUnitWithExp && exp > 0 ? '+' : '';
|
|
1276
|
-
retUnit.assignVals({
|
|
1277
|
-
'name_': theName + '<sup>' + expStr + '</sup>',
|
|
1278
|
-
'csCode_': theCode + intergerUnitExpSign + expStr,
|
|
1279
|
-
'ciCode_': theCiCode + intergerUnitExpSign + expStr,
|
|
1280
|
-
'printSymbol_': thePrintSymbol + '<sup>' + expStr + '</sup>'
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
1267
|
} // end if an original unit was found (without prefix and/or exponent)
|
|
1284
1268
|
} // end if an invalid exponent wasn't found
|
|
1285
1269
|
} // end if we didn't get a unit for the full unit code (w/out modifiers)
|
|
@@ -1288,6 +1272,88 @@ export class UnitString {
|
|
|
1288
1272
|
} // end _makeUnit
|
|
1289
1273
|
|
|
1290
1274
|
|
|
1275
|
+
/**
|
|
1276
|
+
* Checks whether an otherwise unresolved unit code matches a unit name.
|
|
1277
|
+
*
|
|
1278
|
+
* @param uCode the unit code or name to check
|
|
1279
|
+
* @param origString the original full string submitted to parseString
|
|
1280
|
+
* @returns an array containing the unit object found, or null, and origString
|
|
1281
|
+
*/
|
|
1282
|
+
_getUnitByName(uCode, origString) {
|
|
1283
|
+
|
|
1284
|
+
let retUnit = null;
|
|
1285
|
+
let retUnitAry = this.utabs_.getUnitByName(uCode);
|
|
1286
|
+
if (retUnitAry && retUnitAry.length > 0) {
|
|
1287
|
+
retUnit = retUnitAry[0].clone();
|
|
1288
|
+
let mString = 'The UCUM code for ' + uCode + ' is ' +
|
|
1289
|
+
retUnit.csCode_ + '.\n' + this.vcMsgStart_ +
|
|
1290
|
+
retUnit.csCode_ + this.vcMsgEnd_;
|
|
1291
|
+
let dupMsg = false;
|
|
1292
|
+
for (let r = 0; r < this.retMsg_.length && !dupMsg; r++)
|
|
1293
|
+
dupMsg = this.retMsg_[r] === mString;
|
|
1294
|
+
if (!dupMsg)
|
|
1295
|
+
this.retMsg_.push(mString);
|
|
1296
|
+
const escapedCode = uCode.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1297
|
+
let rStr = new RegExp('(^|[./(])(' + escapedCode + ')($|[./)\\-\\d{])');
|
|
1298
|
+
const updatedOrigString = origString.replace(rStr, '$1' + retUnit.csCode_ + '$3');
|
|
1299
|
+
if (updatedOrigString == origString) {
|
|
1300
|
+
// This should not happen, if the processing has been correct. However, if it does happen, we
|
|
1301
|
+
// still have to change origString to signal that the input unit is invalid.
|
|
1302
|
+
// There is a test present to make sure this message does not appear from the top-level APIs in
|
|
1303
|
+
// ucumLhcUtils.js.
|
|
1304
|
+
// Ideally, this problem would be signalled some other way, but that would be a bigger change.
|
|
1305
|
+
origString += ' (Unable to update the unit expression with a suggested replacement.)';
|
|
1306
|
+
}
|
|
1307
|
+
else {
|
|
1308
|
+
origString = updatedOrigString;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return [retUnit, origString];
|
|
1312
|
+
} // end _getUnitByName
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Checks whether an otherwise unresolved unit code can be found after adding
|
|
1317
|
+
* square brackets, e.g., degF -> [degF]. If a bracketed unit is found,
|
|
1318
|
+
* origString is modified to include the suggested replacement.
|
|
1319
|
+
*
|
|
1320
|
+
* @param uCode the unit code to check
|
|
1321
|
+
* @param origString the original full string submitted to parseString
|
|
1322
|
+
* @returns an array containing the unit object found, or null, and the possibly
|
|
1323
|
+
* modified origString
|
|
1324
|
+
*/
|
|
1325
|
+
_getUnitAfterAddingBrackets(uCode, origString) {
|
|
1326
|
+
|
|
1327
|
+
let retUnit = null;
|
|
1328
|
+
const addBrackets = '[' + uCode + ']' ;
|
|
1329
|
+
const bracketUnit = this.utabs_.getUnitByCode(addBrackets);
|
|
1330
|
+
if (bracketUnit) {
|
|
1331
|
+
retUnit = bracketUnit.clone();
|
|
1332
|
+
const escapedCode = uCode.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1333
|
+
const leadingUnitBoundary = '(^|[./(])';
|
|
1334
|
+
const trailingUnitBoundary = '($|[./)\\-\\d{])';
|
|
1335
|
+
const rStr = new RegExp(leadingUnitBoundary + '(' + escapedCode + ')' +
|
|
1336
|
+
trailingUnitBoundary);
|
|
1337
|
+
const updatedOrigString = origString.replace(rStr, '$1' + addBrackets + '$3');
|
|
1338
|
+
if (updatedOrigString == origString) {
|
|
1339
|
+
// This should not happen, if the processing has been correct. However, if it does happen, we
|
|
1340
|
+
// still have to change origString to signal that the input unit is invalid.
|
|
1341
|
+
// There is a test present to make sure this message does not appear from the top-level APIs in
|
|
1342
|
+
// ucumLhcUtils.js.
|
|
1343
|
+
// Ideally, this problem would be signalled some other way, but that would be a bigger change.
|
|
1344
|
+
origString += ' (Unable to update the unit expression with a suggested replacement.)';
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
origString = updatedOrigString;
|
|
1348
|
+
}
|
|
1349
|
+
this.retMsg_.push(`${uCode} is not a valid unit expression, but ` +
|
|
1350
|
+
`${addBrackets} is.\n` + this.vcMsgStart_ +
|
|
1351
|
+
`${addBrackets} (${retUnit.name_})${this.vcMsgEnd_}`);
|
|
1352
|
+
}
|
|
1353
|
+
return [retUnit, origString];
|
|
1354
|
+
} // end _getUnitAfterAddingBrackets
|
|
1355
|
+
|
|
1356
|
+
|
|
1291
1357
|
/**
|
|
1292
1358
|
* This method handles unit creation when an annotation is included
|
|
1293
1359
|
* in the unit string. This basically isolates and retrieves the
|
package/source-cjs/config.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.Ucum = void 0;
|
|
|
12
12
|
* defined by the ECMAScript 6 standard
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
var Ucum = {
|
|
15
|
+
var Ucum = exports.Ucum = {
|
|
16
16
|
/**
|
|
17
17
|
* Flag indicating whether or not we're using case sensitive labels
|
|
18
18
|
* I don't think we need this. I think we're just going with
|
|
@@ -119,5 +119,4 @@ var Ucum = {
|
|
|
119
119
|
'[m/s2/Hz^(1/2)]': 'specialUnitTwo'
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
exports.Ucum = Ucum;
|
|
123
122
|
//# sourceMappingURL=config.js.map
|
package/source-cjs/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["Ucum","dimLen_","validOps_","codeSep_","valMsgStart_","valMsgEnd_","cnvMsgStart_","cnvMsgEnd_","openEmph_","closeEmph_","openEmphHTML_","closeEmphHTML_","bracesMsg_","needMoleWeightMsg_","needEqWeightMsg_","needEqChargeMsg_","csvCols_","inputKey_","specUnits_"
|
|
1
|
+
{"version":3,"file":"config.js","names":["Ucum","exports","dimLen_","validOps_","codeSep_","valMsgStart_","valMsgEnd_","cnvMsgStart_","cnvMsgEnd_","openEmph_","closeEmph_","openEmphHTML_","closeEmphHTML_","bracesMsg_","needMoleWeightMsg_","needEqWeightMsg_","needEqChargeMsg_","csvCols_","inputKey_","specUnits_"],"sources":["../source/config.js"],"sourcesContent":["/*\n * This defines the namespace for the UCUM classes and provides\n * a place for the definition of global variables and constants.\n *\n * The javascript for this UCUM implementation uses syntax as\n * defined by the ECMAScript 6 standard\n */\n\nexport var Ucum = {\n\n /**\n * Flag indicating whether or not we're using case sensitive labels\n * I don't think we need this. I think we're just going with\n * case sensitive, per Clem. Gunther's code has this flag, but I\n * am removing it, at least for now. lm, 6/2016\n */\n //caseSensitive_: true ,\n\n /**\n * The number of elements in a Dimension array. Currently this\n * is set as a configuration variable, but when we get to the point\n * of loading the unit definitions from a file, this value will be\n * set from that.\n */\n dimLen_: 7,\n\n\n /**\n * The characters used as valid operators in a UCUM unit expression,\n * where '.' is for multiplication and '/' is for division.\n */\n validOps_: ['.', '/'],\n\n\n /**\n * The string used to separate a unit code and unit name when they\n * are displayed together\n */\n codeSep_ : ': ',\n\n // Message text variations for validation methods and conversion methods\n valMsgStart_ : 'Did you mean ',\n valMsgEnd_ : '?' ,\n cnvMsgStart_ : 'We assumed you meant ',\n cnvMsgEnd_ : '.',\n\n\n/**\n * Default opening string used to emphasize portions of error messages.\n * Used when NOT displaying messages on a web site, i.e., for output\n * from the library methods or to a file.\n */\n openEmph_ : ' ->',\n\n /**\n * Default closing string used to emphasize portions of error messages.\n * Used when NOT displaying messages on a web site, i.e., for output\n * from the library methods or to a file.\n */\n closeEmph_ : '<- ' ,\n\n /**\n * Opening HTML used to emphasize portions of error messages. Used when\n * displaying messages on a web site; should be blank when output is\n * to a file.\n */\n openEmphHTML_ : ' <span class=\"emphSpan\">',\n\n /**\n * Closing HTML used to emphasize portions of error messages. Used when\n * displaying messages on a web site; should be blank when output is\n * to a file.\n */\n closeEmphHTML_ : '</span> ' ,\n\n /**\n * Message that is displayed when annotations are included in a unit\n * string, to let the user know how they are interpreted.\n */\n bracesMsg_ : 'FYI - annotations (text in curly braces {}) are ignored, ' +\n 'except that an annotation without a leading symbol implies ' +\n 'the default unit 1 (the unity).',\n\n /**\n * Message that is displayed or returned when a conversion is requested\n * for two units where (only) a mass<->moles conversion is appropriate\n * but no molecular weight was specified.\n */\n needMoleWeightMsg_ : 'Did you wish to convert between mass and moles? The ' +\n 'molecular weight of the substance represented by the ' +\n 'units is required to perform the conversion.',\n\n /**\n * Message that is returned when a mass<->eq conversion is requested \n * (which requires a molecular weight to calculate), but no molecular \n * weight was provided by the user.\n */ \n needEqWeightMsg_ : 'Did you wish to convert with equivalents? The ' +\n 'molecular weight of the substance is required to perform ' + \n 'the conversion.', \n\n /**\n * Message that is returned when a mass<->eq or a mol<->eq conversion \n * is requested (which requires a charge to calculate), but no charge\n * was provided by the user.\n */\n needEqChargeMsg_ : 'Did you wish to convert with equivalents? The ' +\n 'charge of the substance is required to perform ' + \n 'the conversion.', \n\n /**\n * Hash that matches unit column names to names used in the csv file\n * that is submitted to the data updater.\n */\n csvCols_ : {\n 'case-sensitive code' : 'csCode_',\n 'LOINC property' : 'loincProperty_',\n 'name (display)' : 'name_',\n 'synonyms' : 'synonyms_',\n 'source' : 'source_',\n 'category' : 'category_',\n 'Guidance' : 'guidance_'\n } ,\n\n /**\n * Name of the column in the csv file that serves as the key\n */\n inputKey_ : 'case-sensitive code' ,\n\n /**\n * Special codes that contain operators within brackets. The operator\n * within these codes causes them to parse incorrectly if they are preceded\n * by a prefix, because the parsing algorithm splits them up on the operator.\n * So we use this object to identify them and substitute placeholders to\n * avoid that.\n */\n specUnits_ : { 'B[10.nV]' : 'specialUnitOne',\n '[m/s2/Hz^(1/2)]' : 'specialUnitTwo'}\n} ;\n\n\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,IAAIA,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAEhB;AACF;AACA;AACA;AACA;AACA;EACE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,OAAO,EAAE,CAAC;EAGV;AACF;AACA;AACA;EACEC,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;EAGrB;AACF;AACA;AACA;EACEC,QAAQ,EAAG,IAAI;EAEf;EACAC,YAAY,EAAG,eAAe;EAC9BC,UAAU,EAAG,GAAG;EAChBC,YAAY,EAAG,uBAAuB;EACtCC,UAAU,EAAG,GAAG;EAGlB;AACA;AACA;AACA;AACA;EACEC,SAAS,EAAG,KAAK;EAEjB;AACF;AACA;AACA;AACA;EACEC,UAAU,EAAG,KAAK;EAElB;AACF;AACA;AACA;AACA;EACEC,aAAa,EAAG,0BAA0B;EAE1C;AACF;AACA;AACA;AACA;EACEC,cAAc,EAAG,UAAU;EAE3B;AACF;AACA;AACA;EACEC,UAAU,EAAG,2DAA2D,GAC3D,6DAA6D,GAC7D,iCAAiC;EAE9C;AACF;AACA;AACA;AACA;EACEC,kBAAkB,EAAG,uDAAuD,GACvD,uDAAuD,GACvD,8CAA8C;EAEnE;AACF;AACA;AACA;AACA;EACEC,gBAAgB,EAAG,iDAAiD,GAChD,2DAA2D,GAC3D,iBAAiB;EAErC;AACF;AACA;AACA;AACA;EACEC,gBAAgB,EAAG,iDAAiD,GAChD,iDAAiD,GACjD,iBAAiB;EAErC;AACF;AACA;AACA;EACEC,QAAQ,EAAG;IACT,qBAAqB,EAAG,SAAS;IACjC,gBAAgB,EAAG,gBAAgB;IACnC,gBAAgB,EAAG,OAAO;IAC1B,UAAU,EAAG,WAAW;IACxB,QAAQ,EAAG,SAAS;IACpB,UAAU,EAAG,WAAW;IACxB,UAAU,EAAG;EACf,CAAC;EAED;AACF;AACA;EACEC,SAAS,EAAG,qBAAqB;EAEjC;AACF;AACA;AACA;AACA;AACA;AACA;EACGC,UAAU,EAAG;IAAE,UAAU,EAAG,gBAAgB;IAC7B,iBAAiB,EAAG;EAAgB;AACtD,CAAC","ignoreList":[]}
|
|
@@ -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,C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;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":[]}
|
|
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;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IAAIC,OAAO,GAAG,IAAI,CAAC1B,OAAO,KAAK,IAAI;IACnC,IAAI,IAAI,CAACA,OAAO,EAAE;MAChB,KAAK,IAAIgB,CAAC,GAAG,CAAC,EAAEU,OAAO,IAAIV,CAAC,GAAG/B,EAAE,CAACM,IAAI,CAACC,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":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.PrefixTablesFactory = exports.PrefixTables = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* The tables of defined prefixes is defined in this file.
|
|
9
9
|
*/
|
|
@@ -120,10 +120,9 @@ class PrefixTablesFactory {
|
|
|
120
120
|
// provides that instance via getInstance().
|
|
121
121
|
exports.PrefixTablesFactory = PrefixTablesFactory;
|
|
122
122
|
var prefixTablesInstance = new PrefixTablesFactory();
|
|
123
|
-
const PrefixTables = {
|
|
123
|
+
const PrefixTables = exports.PrefixTables = {
|
|
124
124
|
getInstance: function () {
|
|
125
125
|
return prefixTablesInstance;
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
exports.PrefixTables = PrefixTables;
|
|
129
128
|
//# sourceMappingURL=prefixTables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefixTables.js","names":["PrefixTablesFactory","constructor","byCode_","byValue_","prefixCount","Object","keys","length","allPrefixesByValue","prefixBuff","pList","pLen","p","pfx","getPrefixByValue","code_","name_","value_","allPrefixesByCode","prefixList","sort","push","getPrefixByCode","add","prefixObj","getCode","getValue","isDefined","code","undefined","value","exports","prefixTablesInstance","PrefixTables","getInstance"],"sources":["../source/prefixTables.js"],"sourcesContent":["/**\n * The tables of defined prefixes is defined in this file.\n */\n\n/**\n * This class implements the table of multiplier prefixes.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\nexport class PrefixTablesFactory {\n\n /**\n * Constructor. This creates the empty PrefixTable hashes once.\n * There is one hash whose key is the prefix code and one whose\n * key is the prefix value.\n *\n * Implementation of this as a singleton is based on the UnitTables\n * implementation. See that class for details.\n */\n constructor(){\n this.byCode_ = {} ;\n this.byValue_ = {};\n }\n\n\n /**\n * Provides the number of prefix objects in each table\n * @returns count of the number of prefix objects in each table\n */\n prefixCount() {\n return Object.keys(this.byCode_).length ;\n }\n\n\n /**\n * This is used to get all prefix objects by value. Currently it is used\n * to create a csv file with all prefixes and units.\n * @returns csv string containing all prefix objects, ordered by value.\n */\n allPrefixesByValue() {\n let prefixBuff = '';\n let pList = Object.keys(this.byValue_);\n //pList.sort() ;\n let pLen = pList.length;\n for (let p = 0; p < pLen; p++) {\n let pfx = this.getPrefixByValue(pList[p]) ;\n prefixBuff += pfx.code_ + ',' + pfx.name_ + ',,' + pfx.value_ + '\\r\\n';\n }\n return prefixBuff ;\n }\n\n /**\n * This is used to get all prefix objects. Currently it is used\n * to get the objects to write to the json ucum definitions file\n * that is used to provide prefix and unit definition objects for\n * conversions and validations.\n *\n * @returns an array containing all prefix objects, ordered by code.\n */\n allPrefixesByCode() {\n let prefixList = [];\n let pList = Object.keys(this.byCode_);\n pList.sort() ;\n let pLen = pList.length;\n for (let p = 0; p < pLen; p++) {\n prefixList.push(this.getPrefixByCode(pList[p])) ;\n }\n return prefixList ;\n }\n\n /**\n * Adds a prefix object to the tables\n *\n * @param prefixObj the object to be added to the tables\n */\n add(prefixObj){\n this.byCode_[prefixObj.getCode()] = prefixObj;\n this.byValue_[prefixObj.getValue()] = prefixObj;\n }\n\n\n /**\n * Tests whether a prefix object is found for a specified code. This\n * is used to determine whether or not a prefix object has been created\n * for the code.\n *\n * @param code the code to be used to find the prefix object\n * @return boolean indicating whether or not a prefix object was found\n * for the specified code\n */\n isDefined(code) {\n return this.byCode_[code] !== null && this.byCode_[code] !== undefined ;\n }\n\n\n /**\n * Obtains a prefix object for a specified code.\n *\n * @param code the code to be used to find the prefix object\n * @return the prefix object found, or null if nothing was found\n */\n getPrefixByCode(code) {\n return this.byCode_[code];\n }\n\n\n /**\n * Obtains a prefix object for a specified value.\n *\n * @param value the value to be used to find the prefix object\n * @return the prefix object found, or null if nothing was found\n */\n getPrefixByValue(value) {\n return this.byValue_[value];\n }\n\n} // end PrefixTablesFactory class\n\n\n// Create a singleton instance and (to preserve the existing API) an object that\n// provides that instance via getInstance().\nvar prefixTablesInstance = new PrefixTablesFactory();\nexport const PrefixTables = {\n getInstance: function() {\n return prefixTablesInstance;\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,CAAC;EAE/B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EAAE;IACX,IAAI,CAACC,OAAO,GAAG,CAAC,CAAC;IACjB,IAAI,CAACC,QAAQ,GAAG,CAAC,CAAC;EACpB;;EAGA;AACF;AACA;AACA;EACEC,WAAWA,CAAA,EAAG;IACZ,OAAOC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACJ,OAAO,CAAC,CAACK,MAAM;EACzC;;EAGA;AACF;AACA;AACA;AACA;EACEC,kBAAkBA,CAAA,EAAG;IACnB,IAAIC,UAAU,GAAG,EA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E;IACd,OAAO,IAAI,CAAC1B,OAAO,CAAC0B,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC1B,OAAO,CAAC0B,IAAI,CAAC,KAAKC,SAAS;EACxE;;EAGA;AACF;AACA;AACA;AACA;AACA;EACEP,eAAeA,CAACM,IAAI,EAAE;IACpB,OAAO,IAAI,CAAC1B,OAAO,CAAC0B,IAAI,CAAC;EAC3B;;EAGA;AACF;AACA;AACA;AACA;AACA;EACEd,gBAAgBA,CAACgB,KAAK,EAAE;IACtB,OAAO,IAAI,CAAC3B,QAAQ,CAAC2B,KAAK,CAAC;EAC7B;AAEF,CAAC,CAAC;;AAGF;AACA;AAAAC,OAAA,CAAA/B,mBAAA,GAAAA,mBAAA;AACA,IAAIgC,oBAAoB,GAAG,IAAIhC,mBAAmB,CAAC,CAAC;AAC7C,MAAMiC,YAAY,GAAG;EAC1BC,WAAW,EAAE,SAAAA,CAAA,EAAW;IACtB,OAAOF,oBAAoB;EAC7B;AACF,CAAC
|
|
1
|
+
{"version":3,"file":"prefixTables.js","names":["PrefixTablesFactory","constructor","byCode_","byValue_","prefixCount","Object","keys","length","allPrefixesByValue","prefixBuff","pList","pLen","p","pfx","getPrefixByValue","code_","name_","value_","allPrefixesByCode","prefixList","sort","push","getPrefixByCode","add","prefixObj","getCode","getValue","isDefined","code","undefined","value","exports","prefixTablesInstance","PrefixTables","getInstance"],"sources":["../source/prefixTables.js"],"sourcesContent":["/**\n * The tables of defined prefixes is defined in this file.\n */\n\n/**\n * This class implements the table of multiplier prefixes.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\nexport class PrefixTablesFactory {\n\n /**\n * Constructor. This creates the empty PrefixTable hashes once.\n * There is one hash whose key is the prefix code and one whose\n * key is the prefix value.\n *\n * Implementation of this as a singleton is based on the UnitTables\n * implementation. See that class for details.\n */\n constructor(){\n this.byCode_ = {} ;\n this.byValue_ = {};\n }\n\n\n /**\n * Provides the number of prefix objects in each table\n * @returns count of the number of prefix objects in each table\n */\n prefixCount() {\n return Object.keys(this.byCode_).length ;\n }\n\n\n /**\n * This is used to get all prefix objects by value. Currently it is used\n * to create a csv file with all prefixes and units.\n * @returns csv string containing all prefix objects, ordered by value.\n */\n allPrefixesByValue() {\n let prefixBuff = '';\n let pList = Object.keys(this.byValue_);\n //pList.sort() ;\n let pLen = pList.length;\n for (let p = 0; p < pLen; p++) {\n let pfx = this.getPrefixByValue(pList[p]) ;\n prefixBuff += pfx.code_ + ',' + pfx.name_ + ',,' + pfx.value_ + '\\r\\n';\n }\n return prefixBuff ;\n }\n\n /**\n * This is used to get all prefix objects. Currently it is used\n * to get the objects to write to the json ucum definitions file\n * that is used to provide prefix and unit definition objects for\n * conversions and validations.\n *\n * @returns an array containing all prefix objects, ordered by code.\n */\n allPrefixesByCode() {\n let prefixList = [];\n let pList = Object.keys(this.byCode_);\n pList.sort() ;\n let pLen = pList.length;\n for (let p = 0; p < pLen; p++) {\n prefixList.push(this.getPrefixByCode(pList[p])) ;\n }\n return prefixList ;\n }\n\n /**\n * Adds a prefix object to the tables\n *\n * @param prefixObj the object to be added to the tables\n */\n add(prefixObj){\n this.byCode_[prefixObj.getCode()] = prefixObj;\n this.byValue_[prefixObj.getValue()] = prefixObj;\n }\n\n\n /**\n * Tests whether a prefix object is found for a specified code. This\n * is used to determine whether or not a prefix object has been created\n * for the code.\n *\n * @param code the code to be used to find the prefix object\n * @return boolean indicating whether or not a prefix object was found\n * for the specified code\n */\n isDefined(code) {\n return this.byCode_[code] !== null && this.byCode_[code] !== undefined ;\n }\n\n\n /**\n * Obtains a prefix object for a specified code.\n *\n * @param code the code to be used to find the prefix object\n * @return the prefix object found, or null if nothing was found\n */\n getPrefixByCode(code) {\n return this.byCode_[code];\n }\n\n\n /**\n * Obtains a prefix object for a specified value.\n *\n * @param value the value to be used to find the prefix object\n * @return the prefix object found, or null if nothing was found\n */\n getPrefixByValue(value) {\n return this.byValue_[value];\n }\n\n} // end PrefixTablesFactory class\n\n\n// Create a singleton instance and (to preserve the existing API) an object that\n// provides that instance via getInstance().\nvar prefixTablesInstance = new PrefixTablesFactory();\nexport const PrefixTables = {\n getInstance: function() {\n return prefixTablesInstance;\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,CAAC;EAE/B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EAAE;IACX,IAAI,CAACC,OAAO,GAAG,CAAC,CAAC;IACjB,IAAI,CAACC,QAAQ,GAAG,CAAC,CAAC;EACpB;;EAGA;AACF;AACA;AACA;EACEC,WAAWA,CAAA,EAAG;IACZ,OAAOC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACJ,OAAO,CAAC,CAACK,MAAM;EACzC;;EAGA;AACF;AACA;AACA;AACA;EACEC,kBAAkBA,CAAA,EAAG;IACnB,IAAIC,UAAU,GAAG,EAAE;IACnB,IAAIC,KAAK,GAAGL,MAAM,CAACC,IAAI,CAAC,IAAI,CAACH,QAAQ,CAAC;IACtC;IACA,IAAIQ,IAAI,GAAGD,KAAK,CAACH,MAAM;IACvB,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,IAAI,EAAEC,CAAC,EAAE,EAAE;MAC7B,IAAIC,GAAG,GAAG,IAAI,CAACC,gBAAgB,CAACJ,KAAK,CAACE,CAAC,CAAC,CAAC;MACzCH,UAAU,IAAII,GAAG,CAACE,KAAK,GAAG,GAAG,GAAGF,GAAG,CAACG,KAAK,GAAG,IAAI,GAAGH,GAAG,CAACI,MAAM,GAAG,MAAM;IACxE;IACA,OAAOR,UAAU;EACnB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACES,iBAAiBA,CAAA,EAAG;IAClB,IAAIC,UAAU,GAAG,EAAE;IACnB,IAAIT,KAAK,GAAGL,MAAM,CAACC,IAAI,CAAC,IAAI,CAACJ,OAAO,CAAC;IACrCQ,KAAK,CAACU,IA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]}
|
|
@@ -229,6 +229,5 @@ class UcumFunctions {
|
|
|
229
229
|
return this.funcs[fname] !== null;
|
|
230
230
|
}
|
|
231
231
|
} // end of UcumFunctions class
|
|
232
|
-
var _default = new UcumFunctions(); // one singleton instance
|
|
233
|
-
exports.default = _default;
|
|
232
|
+
var _default = exports.default = new UcumFunctions(); // one singleton instance
|
|
234
233
|
//# sourceMappingURL=ucumFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ucumFunctions.js","names":["UcumFunctions","constructor","funcs","cnvTo","x","cnvFrom","Math","log","LN10","pow","exp","LN2","tan","atan","sqrt","func","forName","fname","toLowerCase","f","Error","isDefined","_default","exports","default"],"sources":["../source/ucumFunctions.js"],"sourcesContent":["/*\n * This class manages the special functions used by some units.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\n\nclass UcumFunctions {\n\n /**\n * Constructor\n *\n * Creates the singleton object that contains the list of functions used\n * to convert special units.\n */\n constructor() {\n\n // Create the hash containing the function pairs\n this.funcs = {};\n\n // Celsius - convert to Celsius from kelvin and from Celsius to kelvin\n // where kelvin is the base unit for temperature\n this.funcs['cel'] = {cnvTo : function(x){return x - 273.15;},\n cnvFrom : function(x){return x + 273.15;}};\n\n // Fahrenheit - convert to Fahrenheit from kelvin and from Fahrenheit to\n // kelvin - which is the base unit for temperature\n this.funcs['degf'] = {cnvTo : function(x){return x - 459.67;},\n cnvFrom : function(x){return x + 459.67;}};\n\n // Reaumur - convert between Reaumur and Kelvin. Because of the way the\n // calling code in the Units class is set up (in the convertFrom method),\n // what is given here as the convertTo function is actually the convert\n // from method and vice versa.\n //this.funcs['degre'] = {cnvTo : function(x){return x + 273.15;},\n // cnvFrom : function(x){return x - 273.15;}};\n this.funcs['degre'] = {cnvTo : function(x){return x - 273.15;},\n cnvFrom : function(x){return x + 273.15;}};\n\n // pH - convert to pH from moles per liter and from moles per liter to pH\n // where a mole is an amount of a substance (a count of particles)\n this.funcs['ph'] = {cnvTo : function(x){return - Math.log(x) / Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, -x);}};\n\n // ln - natural logarithm (base e 2.71828) - apply (cnvTo) and invert (cnvFrom)\n // and 2ln - two times the natural logarithm\n this.funcs['ln'] = {cnvTo : function(x){return Math.log(x);},\n cnvFrom : function(x){return Math.exp(x);}};\n this.funcs['2ln'] = {cnvTo : function(x){return 2 * Math.log(x);},\n cnvFrom : function(x){return Math.exp(x / 2);}};\n\n // lg - the decadic logarithm (base 10)\n this.funcs['lg'] = {cnvTo : function(x){return Math.log(x) / Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x);}};\n this.funcs['10lg'] = {cnvTo : function(x){return 10 * Math.log(x)/Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x / 10);}};\n this.funcs['20lg'] = {cnvTo : function(x){return 20 * Math.log(x)/Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x / 20);}};\n // The plain text ucum units file uses '2lg'\n this.funcs['2lg'] = {cnvTo : function(x){return 2 * Math.log(x)/Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x / 2);}};\n // The xml essence ucum file uses lgTimes2\n this.funcs['lgtimes2'] = this.funcs['2lg'];\n\n // ld - dual logarithm (base 2)\n this.funcs['ld'] = {cnvTo : function(x){return Math.log(x)/Math.LN2;},\n cnvFrom : function(x){return Math.pow(2, x);}};\n\n // tan - tangent\n this.funcs['100tan'] = {cnvTo : function(x){return Math.tan(x) * 100;},\n cnvFrom : function(x){return Math.atan(x/100);}};\n // the xml essence ucum file uses both 100tan and tanTimes100\n this.funcs['tanTimes100'] = this.funcs['100tan'] ;\n\n // sqrt - square root\n this.funcs['sqrt'] = {cnvTo : function(x){return Math.sqrt(x);},\n cnvFrom : function(x){return x*x;}};\n\n // inv - inverse\n this.funcs['inv'] = {cnvTo : function(x){return 1.0 / x;},\n cnvFrom : function(x){return 1.0 / x;}};\n\n // homeopathic potency functions\n this.funcs['hpX'] = {cnvTo : function(x){return -(this.funcs['lg'](x));},\n cnvFrom : function(x){return Math.pow(10, -x);}};\n\n this.funcs['hpC'] = {cnvTo : function(x){\n return -(this.func['ln'](x))/this.funcs['ln'](100);},\n cnvFrom : function(x){return Math.pow(100, -x);}};\n\n this.funcs['hpM'] = {cnvTo : function(x){\n return -(this.funcs['ln'](x))/this.funcs['ln'](1000);},\n cnvFrom : function(x){return Math.pow(1000, -x);}};\n\n this.funcs['hpQ'] = {cnvTo : function(x){\n return -(this.funcs['ln'](x))/this.funcs['ln'](50000);},\n cnvFrom : function(x){return Math.pow(50000, -x);}};\n\n } // end of constructor\n\n\n /**\n * Returns the function with the name specified\n *\n * @param fname name of the function to be returned\n * @return the function with the specified name\n * @throws an error message if the function is not found\n */\n forName(fname) {\n fname = fname.toLowerCase();\n\n let f = this.funcs[fname] ;\n if (f === null)\n throw(new Error(`Requested function ${fname} is not defined`));\n return f;\n }\n\n\n /**\n * Returns a flag indicating whether or not the function has been\n * defined.\n *\n * @param fname name of the function in question\n * @return true if it has been defined; false if not\n */\n isDefined(fname) {\n fname = fname.toLowerCase();\n return this.funcs[fname] !== null;\n }\n\n} // end of UcumFunctions class\n\nexport default new UcumFunctions(); // one singleton instance\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,aAAa,CAAC;EAElB;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EAAG;IAEZ;IACA,IAAI,CAACC,KAAK,GAAG,CAAC,CAAC;;IAEf;IACA;IACA,IAAI,CAACA,KAAK,CAAC,KAAK,CAAC,GAAG;MAACC,KAAK,EAAK,SAAAA,CAASC,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC,CAAC;MAC5CC,OAAO,EAAG,SAAAA,CAASD,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC;IAAC,CAAC;;IAE5D;IACA;IACA,IAAI,CAACF,KAAK,CAAC,MAAM,CAAC,GAAG;MAACC,KAAK,EAAK,SAA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AC,CAAC;IAEpE,IAAI,CAACF,KAAK,CAAC,KAAK,CAAC,GAAG;MAACC,KAAK,EAAG,SAAAA,CAASC,CAAC,EAAC;QACd,OAAO,CAAE,IAAI,CAACF,KAAK,CAAC,IAAI,CAAC,CAACE,CAAC,CAAE,GAAC,IAAI,CAACF,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;MAAC,CAAC;MAC/DG,OAAO,EAAG,SAAAA,CAASD,CAAC,EAAC;QAAC,OAAOE,IAAI,CAACG,GAAG,CAAC,KAAK,EAAE,CAACL,CAAC,CAAC;MAAC;IAAC,CAAC;EAEvE,CAAC,CAAC;;EAGF;AACF;AACA;AACA;AACA;AACA;AACA;EACEY,OAAOA,CAACC,KAAK,EAAE;IACbA,KAAK,GAAGA,KAAK,CAACC,WAAW,CAAC,CAAC;IAE3B,IAAIC,CAAC,GAAG,IAAI,CAACjB,KAAK,CAACe,KAAK,CAAC;IACzB,IAAIE,CAAC,KAAK,IAAI,EACZ,MAAM,IAAIC,KAAK,CAAE,sBAAqBH,KAAM,iBAAgB,CAAC;IAC/D,OAAOE,CAAC;EACV;;EAGA;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,SAASA,CAACJ,KAAK,EAAE;IACfA,KAAK,GAAGA,KAAK,CAACC,WAAW,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAChB,KAAK,CAACe,KAAK,CAAC,KAAK,IAAI;EACnC;AAEF,CAAC,CAAC;AAAA,IAAAK,QAAA,GAEa,IAAItB,aAAa,CAAC,CAAC,EAAE;AAAAuB,OAAA,CAAAC,OAAA,GAAAF,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ucumFunctions.js","names":["UcumFunctions","constructor","funcs","cnvTo","x","cnvFrom","Math","log","LN10","pow","exp","LN2","tan","atan","sqrt","func","forName","fname","toLowerCase","f","Error","isDefined","_default","exports","default"],"sources":["../source/ucumFunctions.js"],"sourcesContent":["/*\n * This class manages the special functions used by some units.\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\n\nclass UcumFunctions {\n\n /**\n * Constructor\n *\n * Creates the singleton object that contains the list of functions used\n * to convert special units.\n */\n constructor() {\n\n // Create the hash containing the function pairs\n this.funcs = {};\n\n // Celsius - convert to Celsius from kelvin and from Celsius to kelvin\n // where kelvin is the base unit for temperature\n this.funcs['cel'] = {cnvTo : function(x){return x - 273.15;},\n cnvFrom : function(x){return x + 273.15;}};\n\n // Fahrenheit - convert to Fahrenheit from kelvin and from Fahrenheit to\n // kelvin - which is the base unit for temperature\n this.funcs['degf'] = {cnvTo : function(x){return x - 459.67;},\n cnvFrom : function(x){return x + 459.67;}};\n\n // Reaumur - convert between Reaumur and Kelvin. Because of the way the\n // calling code in the Units class is set up (in the convertFrom method),\n // what is given here as the convertTo function is actually the convert\n // from method and vice versa.\n //this.funcs['degre'] = {cnvTo : function(x){return x + 273.15;},\n // cnvFrom : function(x){return x - 273.15;}};\n this.funcs['degre'] = {cnvTo : function(x){return x - 273.15;},\n cnvFrom : function(x){return x + 273.15;}};\n\n // pH - convert to pH from moles per liter and from moles per liter to pH\n // where a mole is an amount of a substance (a count of particles)\n this.funcs['ph'] = {cnvTo : function(x){return - Math.log(x) / Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, -x);}};\n\n // ln - natural logarithm (base e 2.71828) - apply (cnvTo) and invert (cnvFrom)\n // and 2ln - two times the natural logarithm\n this.funcs['ln'] = {cnvTo : function(x){return Math.log(x);},\n cnvFrom : function(x){return Math.exp(x);}};\n this.funcs['2ln'] = {cnvTo : function(x){return 2 * Math.log(x);},\n cnvFrom : function(x){return Math.exp(x / 2);}};\n\n // lg - the decadic logarithm (base 10)\n this.funcs['lg'] = {cnvTo : function(x){return Math.log(x) / Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x);}};\n this.funcs['10lg'] = {cnvTo : function(x){return 10 * Math.log(x)/Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x / 10);}};\n this.funcs['20lg'] = {cnvTo : function(x){return 20 * Math.log(x)/Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x / 20);}};\n // The plain text ucum units file uses '2lg'\n this.funcs['2lg'] = {cnvTo : function(x){return 2 * Math.log(x)/Math.LN10;},\n cnvFrom : function(x){return Math.pow(10, x / 2);}};\n // The xml essence ucum file uses lgTimes2\n this.funcs['lgtimes2'] = this.funcs['2lg'];\n\n // ld - dual logarithm (base 2)\n this.funcs['ld'] = {cnvTo : function(x){return Math.log(x)/Math.LN2;},\n cnvFrom : function(x){return Math.pow(2, x);}};\n\n // tan - tangent\n this.funcs['100tan'] = {cnvTo : function(x){return Math.tan(x) * 100;},\n cnvFrom : function(x){return Math.atan(x/100);}};\n // the xml essence ucum file uses both 100tan and tanTimes100\n this.funcs['tanTimes100'] = this.funcs['100tan'] ;\n\n // sqrt - square root\n this.funcs['sqrt'] = {cnvTo : function(x){return Math.sqrt(x);},\n cnvFrom : function(x){return x*x;}};\n\n // inv - inverse\n this.funcs['inv'] = {cnvTo : function(x){return 1.0 / x;},\n cnvFrom : function(x){return 1.0 / x;}};\n\n // homeopathic potency functions\n this.funcs['hpX'] = {cnvTo : function(x){return -(this.funcs['lg'](x));},\n cnvFrom : function(x){return Math.pow(10, -x);}};\n\n this.funcs['hpC'] = {cnvTo : function(x){\n return -(this.func['ln'](x))/this.funcs['ln'](100);},\n cnvFrom : function(x){return Math.pow(100, -x);}};\n\n this.funcs['hpM'] = {cnvTo : function(x){\n return -(this.funcs['ln'](x))/this.funcs['ln'](1000);},\n cnvFrom : function(x){return Math.pow(1000, -x);}};\n\n this.funcs['hpQ'] = {cnvTo : function(x){\n return -(this.funcs['ln'](x))/this.funcs['ln'](50000);},\n cnvFrom : function(x){return Math.pow(50000, -x);}};\n\n } // end of constructor\n\n\n /**\n * Returns the function with the name specified\n *\n * @param fname name of the function to be returned\n * @return the function with the specified name\n * @throws an error message if the function is not found\n */\n forName(fname) {\n fname = fname.toLowerCase();\n\n let f = this.funcs[fname] ;\n if (f === null)\n throw(new Error(`Requested function ${fname} is not defined`));\n return f;\n }\n\n\n /**\n * Returns a flag indicating whether or not the function has been\n * defined.\n *\n * @param fname name of the function in question\n * @return true if it has been defined; false if not\n */\n isDefined(fname) {\n fname = fname.toLowerCase();\n return this.funcs[fname] !== null;\n }\n\n} // end of UcumFunctions class\n\nexport default new UcumFunctions(); // one singleton instance\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,aAAa,CAAC;EAElB;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAAA,EAAG;IAEZ;IACA,IAAI,CAACC,KAAK,GAAG,CAAC,CAAC;;IAEf;IACA;IACA,IAAI,CAACA,KAAK,CAAC,KAAK,CAAC,GAAG;MAACC,KAAK,EAAK,SAAAA,CAASC,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC,CAAC;MAC5CC,OAAO,EAAG,SAAAA,CAASD,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC;IAAC,CAAC;;IAE5D;IACA;IACA,IAAI,CAACF,KAAK,CAAC,MAAM,CAAC,GAAG;MAACC,KAAK,EAAK,SAAAA,CAASC,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC,CAAC;MAC5CC,OAAO,EAAG,SAAAA,CAASD,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC;IAAC,CAAC;;IAE7D;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,CAACF,KAAK,CAAC,OAAO,CAAC,GAAG;MAACC,KAAK,EAAK,SAAAA,CAASC,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC,CAAC;MAC5CC,OAAO,EAAG,SAAAA,CAASD,CAAC,EAAC;QAAC,OAAOA,CAAC,GAAG,MAAM;MAAC;IAAC,CAAC;;IAE9D;IACA;IACA,IAAI,CAACF,KAAK,CAAC,IAAI,CAAC,GAAG;MAACC,KAAK,EAAI,SAAAA,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CAAC;IAE3B,IAAIC,CAAC,GAAG,IAAI,CAACjB,KAAK,CAACe,KAAK,CAAC;IACzB,IAAIE,CAAC,KAAK,IAAI,EACZ,MAAM,IAAIC,KAAK,CAAC,sBAAsBH,KAAK,iBAAiB,CAAC;IAC/D,OAAOE,CAAC;EACV;;EAGA;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,SAASA,CAACJ,KAAK,EAAE;IACfA,KAAK,GAAGA,KAAK,CAACC,WAAW,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAChB,KAAK,CAACe,KAAK,CAAC,KAAK,IAAI;EACnC;AAEF,CAAC,CAAC;AAAA,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAIxB,aAAa,CAAC,CAAC,EAAE","ignoreList":[]}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isNumericString = isNumericString;
|
|
7
|
-
exports.isIntegerUnit = isIntegerUnit;
|
|
8
6
|
exports.getSynonyms = getSynonyms;
|
|
7
|
+
exports.isIntegerUnit = isIntegerUnit;
|
|
8
|
+
exports.isNumericString = isNumericString;
|
|
9
9
|
/**
|
|
10
10
|
* Internal utilities used by multiple UCUM classes. For example,
|
|
11
11
|
* isNumericString is used by both the UnitString and UcumLhcUtils
|