@lhncbc/ucum-lhc 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -12
- package/browser-dist/ucum-lhc.js +731 -1265
- package/data/ucumDefs.min.json +1 -1
- package/package.json +1 -1
- package/source/ucumLhcUtils.js +2 -2
- package/source/ucumXmlDocument.js +5 -2
- package/source/unit.js +2 -1
- package/source/unitString.js +142 -130
- package/source-cjs/config.js +1 -12
- package/source-cjs/config.js.map +1 -1
- package/source-cjs/dimension.js +20 -63
- package/source-cjs/dimension.js.map +1 -1
- package/source-cjs/jsonArrayPack.js +7 -25
- package/source-cjs/jsonArrayPack.js.map +1 -1
- package/source-cjs/prefix.js +12 -26
- package/source-cjs/prefix.js.map +1 -1
- package/source-cjs/prefixTables.js +10 -24
- package/source-cjs/prefixTables.js.map +1 -1
- package/source-cjs/ucumFunctions.js +35 -32
- package/source-cjs/ucumFunctions.js.map +1 -1
- package/source-cjs/ucumInternalUtils.js +5 -13
- package/source-cjs/ucumInternalUtils.js.map +1 -1
- package/source-cjs/ucumJsonDefs.js +1 -16
- package/source-cjs/ucumJsonDefs.js.map +1 -1
- package/source-cjs/ucumLhcUtils.js +28 -92
- package/source-cjs/ucumLhcUtils.js.map +1 -1
- package/source-cjs/ucumPkg.js +1 -6
- package/source-cjs/ucumPkg.js.map +1 -1
- package/source-cjs/ucumXmlDocument.js +162 -184
- package/source-cjs/ucumXmlDocument.js.map +1 -1
- package/source-cjs/unit.js +97 -181
- package/source-cjs/unit.js.map +1 -1
- package/source-cjs/unitString.js +521 -608
- package/source-cjs/unitString.js.map +1 -1
- package/source-cjs/unitTables.js +33 -139
- package/source-cjs/unitTables.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lhncbc/ucum-lhc",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
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/",
|
package/source/ucumLhcUtils.js
CHANGED
|
@@ -337,7 +337,7 @@ export class UcumLhcUtils {
|
|
|
337
337
|
* 'invalid': fromUnit is not a valid UCUM code;
|
|
338
338
|
* 'failed': the conversion could not be made (e.g., if it is an "arbitrary" unit);
|
|
339
339
|
* 'error': if an error occurred (an input or programming error)
|
|
340
|
-
* 'msg': an array of
|
|
340
|
+
* 'msg': an array of messages (possibly empty) if the string is invalid or
|
|
341
341
|
* an error occurred, indicating the problem, or a suggestion of a
|
|
342
342
|
* substitution such as the substitution of 'G' for 'Gauss', or
|
|
343
343
|
* an empty array if no messages were generated. There can also be a
|
|
@@ -348,7 +348,7 @@ export class UcumLhcUtils {
|
|
|
348
348
|
* between fromUnit and the base units, so the returned magnitude is likely not
|
|
349
349
|
* useful as a scale factor for other conversions (i.e., it only has validity
|
|
350
350
|
* and usefulness for the input values that produced it).
|
|
351
|
-
* 'unitToExp': a map of base units in
|
|
351
|
+
* 'unitToExp': a map of base units in fromUnit to their exponent
|
|
352
352
|
*/
|
|
353
353
|
convertToBaseUnits(fromUnit, fromVal) {
|
|
354
354
|
let retObj = {};
|
|
@@ -116,7 +116,10 @@ export class UcumXmlDocument {
|
|
|
116
116
|
attrs["exp_"] = pValNode.childNamed('sup');
|
|
117
117
|
if (attrs["exp_"] != null) {
|
|
118
118
|
attrs["exp_"] = attrs["exp_"].val;
|
|
119
|
-
|
|
119
|
+
// Use parseFloat('1eSOMETHING') instead of Math.pow() to avoid
|
|
120
|
+
// small number changes like 1.0000000000000001e-21. See LF-2830.
|
|
121
|
+
// attrs["value_"] = Math.pow(10, attrs["exp_"]);
|
|
122
|
+
attrs["value_"] = parseFloat(`1e${attrs["exp_"]}`);
|
|
120
123
|
}
|
|
121
124
|
else {
|
|
122
125
|
attrs["value_"] = pValNode.val;
|
|
@@ -519,4 +522,4 @@ UcumXmlDocument.getInstance = function(){
|
|
|
519
522
|
|
|
520
523
|
// Perform the first request for the document object, to get the
|
|
521
524
|
// getInstance method set.
|
|
522
|
-
UcumXmlDocument.getInstance();
|
|
525
|
+
UcumXmlDocument.getInstance();
|
package/source/unit.js
CHANGED
|
@@ -839,7 +839,8 @@ export class Unit {
|
|
|
839
839
|
invertString(theString) {
|
|
840
840
|
|
|
841
841
|
if (theString.length > 0) {
|
|
842
|
-
|
|
842
|
+
// replace('<!', '</') is here to make sure closing html tags like </sup> are intact. See LF-2830.
|
|
843
|
+
let stringRep = theString.replace('/', "!").replace('.', '/').replace('<!', '</').replace("!", '.');
|
|
843
844
|
switch(stringRep.charAt(0)) {
|
|
844
845
|
case '.' : theString = stringRep.substr(1); break;
|
|
845
846
|
case '/' : theString = stringRep; break;
|
package/source/unitString.js
CHANGED
|
@@ -878,11 +878,16 @@ export class UnitString {
|
|
|
878
878
|
else {
|
|
879
879
|
|
|
880
880
|
if (intUtils_.isNumericString(aftText)) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
881
|
+
retUnit = null;
|
|
882
|
+
let msg = `An exponent (${aftText}) following a parenthesis ` +
|
|
883
|
+
`is invalid as of revision 1.9 of the UCUM Specification.`;
|
|
884
|
+
// Add the suggestion only if the string in the parenthesis don't end with a number.
|
|
885
|
+
if (!pStr.match(/\d$/)) {
|
|
886
|
+
pStr += aftText;
|
|
887
|
+
msg += '\n ' + this.vcMsgStart_ + pStr + this.vcMsgEnd_;
|
|
888
|
+
}
|
|
889
|
+
this.retMsg_.push(msg);
|
|
890
|
+
endProcessing = true;
|
|
886
891
|
}
|
|
887
892
|
// else the text after the parentheses is neither a number nor
|
|
888
893
|
// an annotation. If suggestions were NOT requested, record an
|
|
@@ -1149,143 +1154,150 @@ export class UnitString {
|
|
|
1149
1154
|
origUnit = this.utabs_.getUnitByCode(uCode);
|
|
1150
1155
|
}
|
|
1151
1156
|
|
|
1157
|
+
// If an exponent is found but it's not a valid number, e.g. "2-1",
|
|
1158
|
+
// mark the unit invalid. Otherwise, the "-1" part will be ignored
|
|
1159
|
+
// because parseInt("2-1") results in 2. See LF-2870.
|
|
1160
|
+
if (exp && isNaN(exp)) {
|
|
1161
|
+
retUnit = null;
|
|
1162
|
+
this.retMsg_.push(`${origCode} is not a valid UCUM code.`);
|
|
1163
|
+
}
|
|
1164
|
+
else {
|
|
1165
|
+
// If we still don't have a unit, separate out the prefix, if any,
|
|
1166
|
+
// and try without it.
|
|
1167
|
+
if (!origUnit) {
|
|
1168
|
+
// Try for a single character prefix first.
|
|
1169
|
+
pfxCode = uCode.charAt(0);
|
|
1170
|
+
pfxObj = this.pfxTabs_.getPrefixByCode(pfxCode);
|
|
1171
|
+
|
|
1172
|
+
// if we got a prefix, get its info and remove it from the unit code
|
|
1173
|
+
if (pfxObj) {
|
|
1174
|
+
pfxVal = pfxObj.getValue();
|
|
1175
|
+
pfxExp = pfxObj.getExp();
|
|
1176
|
+
let pCodeLen = pfxCode.length;
|
|
1177
|
+
uCode = uCode.substr(pCodeLen);
|
|
1152
1178
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
if (!origUnit) {
|
|
1156
|
-
// Try for a single character prefix first.
|
|
1157
|
-
pfxCode = uCode.charAt(0);
|
|
1158
|
-
pfxObj = this.pfxTabs_.getPrefixByCode(pfxCode);
|
|
1159
|
-
|
|
1160
|
-
// if we got a prefix, get its info and remove it from the unit code
|
|
1161
|
-
if (pfxObj) {
|
|
1162
|
-
pfxVal = pfxObj.getValue();
|
|
1163
|
-
pfxExp = pfxObj.getExp();
|
|
1164
|
-
let pCodeLen = pfxCode.length;
|
|
1165
|
-
uCode = uCode.substr(pCodeLen);
|
|
1179
|
+
// try again for the unit
|
|
1180
|
+
origUnit = this.utabs_.getUnitByCode(uCode);
|
|
1166
1181
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1182
|
+
// If we still don't have a unit, see if the prefix could be the
|
|
1183
|
+
// two character "da" (deka) prefix. That's the only prefix with
|
|
1184
|
+
// two characters, and without this check it's interpreted as "d"
|
|
1185
|
+
// (deci) and the "a" is considered part of the unit code.
|
|
1169
1186
|
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1187
|
+
if (!origUnit && pfxCode == 'd' && uCode.substr(0, 1) == 'a') {
|
|
1188
|
+
pfxCode = 'da';
|
|
1189
|
+
pfxObj = this.pfxTabs_.getPrefixByCode(pfxCode);
|
|
1190
|
+
pfxVal = pfxObj.getValue();
|
|
1191
|
+
uCode = uCode.substr(1);
|
|
1174
1192
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
pfxVal = pfxObj.getValue();
|
|
1179
|
-
uCode = uCode.substr(1);
|
|
1193
|
+
// try one more time for the unit
|
|
1194
|
+
origUnit = this.utabs_.getUnitByCode(uCode);
|
|
1195
|
+
}
|
|
1180
1196
|
|
|
1181
|
-
//
|
|
1182
|
-
|
|
1197
|
+
// Reject the unit we found if it might have another prefix.
|
|
1198
|
+
// Such things are in our tables through the LOINC source_
|
|
1199
|
+
// (ucum.csv) which has guidance and synonyms. I think it should be
|
|
1200
|
+
// safe to exclude anything whose source is LOINC from having a
|
|
1201
|
+
// prefix.
|
|
1202
|
+
if (origUnit && origUnit.source_ == 'LOINC')
|
|
1203
|
+
origUnit = null;
|
|
1204
|
+
} // end if we found a prefix
|
|
1205
|
+
} // end if we didn't get a unit after removing an exponent
|
|
1206
|
+
|
|
1207
|
+
// If we still haven't found anything, we're done looking.
|
|
1208
|
+
// (We tried with the full unit string, with the unit string
|
|
1209
|
+
// without the exponent, the unit string without a prefix,
|
|
1210
|
+
// common errors, etc. That's all we can try).
|
|
1211
|
+
if (!origUnit) {
|
|
1212
|
+
retUnit = null ;
|
|
1213
|
+
// BUT if the user asked for suggestions, at least look for them
|
|
1214
|
+
if (this.suggestions_) {
|
|
1215
|
+
let suggestStat = this._getSuggestions(origCode);
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
this.retMsg_.push(`${origCode} is not a valid UCUM code.`);
|
|
1183
1219
|
}
|
|
1184
|
-
|
|
1185
|
-
// Reject the unit we found if it might have another prefix.
|
|
1186
|
-
// Such things are in our tables through the LOINC source_
|
|
1187
|
-
// (ucum.csv) which has guidance and synonyms. I think it should be
|
|
1188
|
-
// safe to exclude anything whose source is LOINC from having a
|
|
1189
|
-
// prefix.
|
|
1190
|
-
if (origUnit && origUnit.source_ == 'LOINC')
|
|
1191
|
-
origUnit = null;
|
|
1192
|
-
} // end if we found a prefix
|
|
1193
|
-
} // end if we didn't get a unit after removing an exponent
|
|
1194
|
-
|
|
1195
|
-
// If we still haven't found anything, we're done looking.
|
|
1196
|
-
// (We tried with the full unit string, with the unit string
|
|
1197
|
-
// without the exponent, the unit string without a prefix,
|
|
1198
|
-
// common errors, etc. That's all we can try).
|
|
1199
|
-
if (!origUnit) {
|
|
1200
|
-
retUnit = null ;
|
|
1201
|
-
// BUT if the user asked for suggestions, at least look for them
|
|
1202
|
-
if (this.suggestions_) {
|
|
1203
|
-
let suggestStat = this._getSuggestions(origCode);
|
|
1204
1220
|
}
|
|
1205
1221
|
else {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1222
|
+
// Otherwise we found a unit object. Clone it and then apply the
|
|
1223
|
+
// prefix and exponent, if any, to it. And remove the guidance.
|
|
1224
|
+
retUnit = origUnit.clone();
|
|
1225
|
+
// If we are here, this is only part of the full unit string, so it is
|
|
1226
|
+
// not a base unit, and the synonyms will mostly likely not be correct for the full
|
|
1227
|
+
// string.
|
|
1228
|
+
retUnit.resetFieldsForDerivedUnit();
|
|
1229
|
+
let theDim = retUnit.getProperty('dim_');
|
|
1230
|
+
let theMag = retUnit.getProperty('magnitude_');
|
|
1231
|
+
let theName = retUnit.getProperty('name_');
|
|
1232
|
+
let theCiCode = retUnit.getProperty('ciCode_');
|
|
1233
|
+
let thePrintSymbol = retUnit.getProperty('printSymbol_');
|
|
1234
|
+
// If there is an exponent for the unit, apply it to the dimension
|
|
1235
|
+
// and magnitude now
|
|
1236
|
+
if (exp) {
|
|
1237
|
+
exp = parseInt(exp);
|
|
1238
|
+
let expMul = exp;
|
|
1239
|
+
if (theDim)
|
|
1240
|
+
theDim = theDim.mul(exp);
|
|
1241
|
+
theMag = Math.pow(theMag, exp);
|
|
1242
|
+
retUnit.assignVals({'magnitude_': theMag});
|
|
1243
|
+
|
|
1244
|
+
// If there is also a prefix, apply the exponent to the prefix.
|
|
1245
|
+
if (pfxObj) {
|
|
1246
|
+
|
|
1247
|
+
// if the prefix base is 10 it will have an exponent. Multiply
|
|
1248
|
+
// the current prefix exponent by the exponent for the unit
|
|
1249
|
+
// we're working with. Then raise the prefix value to the level
|
|
1250
|
+
// defined by the exponent.
|
|
1251
|
+
if (pfxExp) {
|
|
1252
|
+
expMul *= pfxObj.getExp();
|
|
1253
|
+
pfxVal = Math.pow(10, expMul);
|
|
1254
|
+
}
|
|
1255
|
+
// If the prefix base is not 10, it won't have an exponent.
|
|
1256
|
+
// At the moment I don't see any units using the prefixes
|
|
1257
|
+
// that aren't base 10. But if we get one the prefix value
|
|
1258
|
+
// will be applied to the magnitude (below) if the unit does
|
|
1259
|
+
// not have a conversion function, and to the conversion prefix
|
|
1260
|
+
// if it does.
|
|
1261
|
+
} // end if there's a prefix as well as the exponent
|
|
1262
|
+
} // end if there's an exponent
|
|
1263
|
+
|
|
1264
|
+
// Now apply the prefix, if there is one, to the conversion
|
|
1265
|
+
// prefix or the magnitude
|
|
1233
1266
|
if (pfxObj) {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
expMul *= pfxObj.getExp();
|
|
1241
|
-
pfxVal = Math.pow(10, expMul);
|
|
1267
|
+
if (retUnit.cnv_) {
|
|
1268
|
+
retUnit.assignVals({'cnvPfx_': pfxVal});
|
|
1269
|
+
}
|
|
1270
|
+
else {
|
|
1271
|
+
theMag *= pfxVal;
|
|
1272
|
+
retUnit.assignVals({'magnitude_': theMag})
|
|
1242
1273
|
}
|
|
1243
|
-
// If the prefix base is not 10, it won't have an exponent.
|
|
1244
|
-
// At the moment I don't see any units using the prefixes
|
|
1245
|
-
// that aren't base 10. But if we get one the prefix value
|
|
1246
|
-
// will be applied to the magnitude (below) if the unit does
|
|
1247
|
-
// not have a conversion function, and to the conversion prefix
|
|
1248
|
-
// if it does.
|
|
1249
|
-
} // end if there's a prefix as well as the exponent
|
|
1250
|
-
} // end if there's an exponent
|
|
1251
|
-
|
|
1252
|
-
// Now apply the prefix, if there is one, to the conversion
|
|
1253
|
-
// prefix or the magnitude
|
|
1254
|
-
if (pfxObj) {
|
|
1255
|
-
if (retUnit.cnv_) {
|
|
1256
|
-
retUnit.assignVals({'cnvPfx_': pfxVal});
|
|
1257
1274
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1275
|
+
// if we have a prefix and/or an exponent, add them to the unit
|
|
1276
|
+
// attributes - name, csCode, ciCode and print symbol
|
|
1277
|
+
let theCode = retUnit.csCode_;
|
|
1278
|
+
if (pfxObj) {
|
|
1279
|
+
theName = pfxObj.getName() + theName;
|
|
1280
|
+
theCode = pfxCode + theCode;
|
|
1281
|
+
theCiCode = pfxObj.getCiCode() + theCiCode;
|
|
1282
|
+
thePrintSymbol = pfxObj.getPrintSymbol() + thePrintSymbol;
|
|
1283
|
+
retUnit.assignVals({
|
|
1284
|
+
'name_': theName,
|
|
1285
|
+
'csCode_': theCode,
|
|
1286
|
+
'ciCode_': theCiCode,
|
|
1287
|
+
'printSymbol_': thePrintSymbol
|
|
1288
|
+
});
|
|
1261
1289
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
'csCode_': theCode,
|
|
1274
|
-
'ciCode_': theCiCode,
|
|
1275
|
-
'printSymbol_': thePrintSymbol
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
if (exp) {
|
|
1279
|
-
let expStr = exp.toString();
|
|
1280
|
-
retUnit.assignVals({
|
|
1281
|
-
'name_': theName + '<sup>' + expStr + '</sup>',
|
|
1282
|
-
'csCode_': theCode + expStr,
|
|
1283
|
-
'ciCode_': theCiCode + expStr,
|
|
1284
|
-
'printSymbol_': thePrintSymbol + '<sup>' + expStr + '</sup>'
|
|
1285
|
-
});
|
|
1286
|
-
}
|
|
1287
|
-
} // end if an original unit was found (without prefix and/or exponent)
|
|
1288
|
-
|
|
1290
|
+
if (exp) {
|
|
1291
|
+
let expStr = exp.toString();
|
|
1292
|
+
retUnit.assignVals({
|
|
1293
|
+
'name_': theName + '<sup>' + expStr + '</sup>',
|
|
1294
|
+
'csCode_': theCode + expStr,
|
|
1295
|
+
'ciCode_': theCiCode + expStr,
|
|
1296
|
+
'printSymbol_': thePrintSymbol + '<sup>' + expStr + '</sup>'
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
} // end if an original unit was found (without prefix and/or exponent)
|
|
1300
|
+
} // end if an invalid exponent wasn't found
|
|
1289
1301
|
} // end if we didn't get a unit for the full unit code (w/out modifiers)
|
|
1290
1302
|
} // end if we didn't find the unit on the first try, before parsing
|
|
1291
1303
|
return [retUnit, origString];
|
package/source-cjs/config.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Ucum = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* This defines the namespace for the UCUM classes and provides
|
|
10
9
|
* a place for the definition of global variables and constants.
|
|
@@ -12,6 +11,7 @@ exports.Ucum = void 0;
|
|
|
12
11
|
* The javascript for this UCUM implementation uses syntax as
|
|
13
12
|
* defined by the ECMAScript 6 standard
|
|
14
13
|
*/
|
|
14
|
+
|
|
15
15
|
var Ucum = {
|
|
16
16
|
/**
|
|
17
17
|
* Flag indicating whether or not we're using case sensitive labels
|
|
@@ -28,13 +28,11 @@ var Ucum = {
|
|
|
28
28
|
* set from that.
|
|
29
29
|
*/
|
|
30
30
|
dimLen_: 7,
|
|
31
|
-
|
|
32
31
|
/**
|
|
33
32
|
* The characters used as valid operators in a UCUM unit expression,
|
|
34
33
|
* where '.' is for multiplication and '/' is for division.
|
|
35
34
|
*/
|
|
36
35
|
validOps_: ['.', '/'],
|
|
37
|
-
|
|
38
36
|
/**
|
|
39
37
|
* The string used to separate a unit code and unit name when they
|
|
40
38
|
* are displayed together
|
|
@@ -45,48 +43,41 @@ var Ucum = {
|
|
|
45
43
|
valMsgEnd_: '?',
|
|
46
44
|
cnvMsgStart_: 'We assumed you meant ',
|
|
47
45
|
cnvMsgEnd_: '.',
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
* Default opening string used to emphasize portions of error messages.
|
|
51
48
|
* Used when NOT displaying messages on a web site, i.e., for output
|
|
52
49
|
* from the library methods or to a file.
|
|
53
50
|
*/
|
|
54
51
|
openEmph_: ' ->',
|
|
55
|
-
|
|
56
52
|
/**
|
|
57
53
|
* Default closing string used to emphasize portions of error messages.
|
|
58
54
|
* Used when NOT displaying messages on a web site, i.e., for output
|
|
59
55
|
* from the library methods or to a file.
|
|
60
56
|
*/
|
|
61
57
|
closeEmph_: '<- ',
|
|
62
|
-
|
|
63
58
|
/**
|
|
64
59
|
* Opening HTML used to emphasize portions of error messages. Used when
|
|
65
60
|
* displaying messages on a web site; should be blank when output is
|
|
66
61
|
* to a file.
|
|
67
62
|
*/
|
|
68
63
|
openEmphHTML_: ' <span class="emphSpan">',
|
|
69
|
-
|
|
70
64
|
/**
|
|
71
65
|
* Closing HTML used to emphasize portions of error messages. Used when
|
|
72
66
|
* displaying messages on a web site; should be blank when output is
|
|
73
67
|
* to a file.
|
|
74
68
|
*/
|
|
75
69
|
closeEmphHTML_: '</span> ',
|
|
76
|
-
|
|
77
70
|
/**
|
|
78
71
|
* Message that is displayed when annotations are included in a unit
|
|
79
72
|
* string, to let the user know how they are interpreted.
|
|
80
73
|
*/
|
|
81
74
|
bracesMsg_: 'FYI - annotations (text in curly braces {}) are ignored, ' + 'except that an annotation without a leading symbol implies ' + 'the default unit 1 (the unity).',
|
|
82
|
-
|
|
83
75
|
/**
|
|
84
76
|
* Message that is displayed or returned when a conversion is requested
|
|
85
77
|
* for two units where (only) a mass<->moles conversion is appropriate
|
|
86
78
|
* but no molecular weight was specified.
|
|
87
79
|
*/
|
|
88
80
|
needMoleWeightMsg_: 'Did you wish to convert between mass and moles? The ' + 'molecular weight of the substance represented by the ' + 'units is required to perform the conversion.',
|
|
89
|
-
|
|
90
81
|
/**
|
|
91
82
|
* Hash that matches unit column names to names used in the csv file
|
|
92
83
|
* that is submitted to the data updater.
|
|
@@ -100,12 +91,10 @@ var Ucum = {
|
|
|
100
91
|
'category': 'category_',
|
|
101
92
|
'Guidance': 'guidance_'
|
|
102
93
|
},
|
|
103
|
-
|
|
104
94
|
/**
|
|
105
95
|
* Name of the column in the csv file that serves as the key
|
|
106
96
|
*/
|
|
107
97
|
inputKey_: 'case-sensitive code',
|
|
108
|
-
|
|
109
98
|
/**
|
|
110
99
|
* Special codes that contain operators within brackets. The operator
|
|
111
100
|
* within these codes causes them to parse incorrectly if they are preceded
|
package/source-cjs/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"config.js","names":["Ucum","dimLen_","validOps_","codeSep_","valMsgStart_","valMsgEnd_","cnvMsgStart_","cnvMsgEnd_","openEmph_","closeEmph_","openEmphHTML_","closeEmphHTML_","bracesMsg_","needMoleWeightMsg_","csvCols_","inputKey_","specUnits_","exports"],"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 * 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,GAAG;EAEhB;AACF;AACA;AACA;AACA;AACA;EACE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,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;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;AAAEC,OAAA,CAAAjB,IAAA,GAAAA,IAAA"}
|