@lhncbc/ucum-lhc 5.0.0 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -12
- package/browser-dist/ucum-lhc.js +731 -1265
- package/data/ucumDefs.min.json +1 -1
- package/package.json +1 -1
- package/source/ucumLhcUtils.js +2 -2
- package/source/ucumXmlDocument.js +5 -2
- package/source/unit.js +2 -1
- package/source/unitString.js +142 -130
- package/source-cjs/config.js +1 -12
- package/source-cjs/config.js.map +1 -1
- package/source-cjs/dimension.js +20 -63
- package/source-cjs/dimension.js.map +1 -1
- package/source-cjs/jsonArrayPack.js +7 -25
- package/source-cjs/jsonArrayPack.js.map +1 -1
- package/source-cjs/prefix.js +12 -26
- package/source-cjs/prefix.js.map +1 -1
- package/source-cjs/prefixTables.js +10 -24
- package/source-cjs/prefixTables.js.map +1 -1
- package/source-cjs/ucumFunctions.js +35 -32
- package/source-cjs/ucumFunctions.js.map +1 -1
- package/source-cjs/ucumInternalUtils.js +5 -13
- package/source-cjs/ucumInternalUtils.js.map +1 -1
- package/source-cjs/ucumJsonDefs.js +1 -16
- package/source-cjs/ucumJsonDefs.js.map +1 -1
- package/source-cjs/ucumLhcUtils.js +28 -92
- package/source-cjs/ucumLhcUtils.js.map +1 -1
- package/source-cjs/ucumPkg.js +1 -6
- package/source-cjs/ucumPkg.js.map +1 -1
- package/source-cjs/ucumXmlDocument.js +162 -184
- package/source-cjs/ucumXmlDocument.js.map +1 -1
- package/source-cjs/unit.js +97 -181
- package/source-cjs/unit.js.map +1 -1
- package/source-cjs/unitString.js +521 -608
- package/source-cjs/unitString.js.map +1 -1
- package/source-cjs/unitTables.js +33 -139
- package/source-cjs/unitTables.js.map +1 -1
package/source-cjs/prefix.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Prefix = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Prefix objects are defined in this file.
|
|
10
9
|
*/
|
|
@@ -17,7 +16,6 @@ exports.Prefix = void 0;
|
|
|
17
16
|
*
|
|
18
17
|
*/
|
|
19
18
|
var Ucum = require('./config.js');
|
|
20
|
-
|
|
21
19
|
class Prefix {
|
|
22
20
|
/**
|
|
23
21
|
* Creates a single prefix object.
|
|
@@ -43,6 +41,7 @@ class Prefix {
|
|
|
43
41
|
if (attrs['code_'] === undefined || attrs['code_'] === null || attrs['name_'] === undefined || attrs['name_'] === null || attrs['value_'] === undefined || attrs['value_'] === null || attrs['exp_'] === undefined) {
|
|
44
42
|
throw new Error('Prefix constructor called missing one or more parameters. ' + 'Prefix codes (cs or ci), name, value and exponent must all be specified ' + 'and all but the exponent must not be null.');
|
|
45
43
|
}
|
|
44
|
+
|
|
46
45
|
/**
|
|
47
46
|
* The prefix code, e.g., k for kilo. This should be the case-sensitive
|
|
48
47
|
* code. Since there's no way to check to see if it's the case-sensitive
|
|
@@ -51,34 +50,32 @@ class Prefix {
|
|
|
51
50
|
* codes are also all uppercase), we'll just have to believe that the
|
|
52
51
|
* right one was passed in.
|
|
53
52
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
53
|
this.code_ = attrs['code_'];
|
|
54
|
+
|
|
57
55
|
/**
|
|
58
56
|
* The case-insensitive code, e.g., K for kilo
|
|
59
57
|
*/
|
|
60
|
-
|
|
61
58
|
this.ciCode_ = attrs['ciCode_'];
|
|
59
|
+
|
|
62
60
|
/**
|
|
63
61
|
* The prefix name, e.g., kilo
|
|
64
62
|
*/
|
|
65
|
-
|
|
66
63
|
this.name_ = attrs['name_'];
|
|
64
|
+
|
|
67
65
|
/**
|
|
68
66
|
* The printSymbol for the prefix, e.g., k for kilo
|
|
69
67
|
*/
|
|
70
|
-
|
|
71
68
|
this.printSymbol_ = attrs['printSymbol_'];
|
|
69
|
+
|
|
72
70
|
/**
|
|
73
71
|
* The value to use in multiplying the magnitude of a unit
|
|
74
72
|
*/
|
|
75
|
-
|
|
76
73
|
if (typeof attrs['value_'] === 'string') this.value_ = parseFloat(attrs['value_']);else this.value_ = attrs['value_'];
|
|
74
|
+
|
|
77
75
|
/**
|
|
78
76
|
* The exponent used to create the value from 10. For prefixes that are
|
|
79
77
|
* not based on 10, this will be null.
|
|
80
78
|
*/
|
|
81
|
-
|
|
82
79
|
this.exp_ = attrs['exp_'];
|
|
83
80
|
} // end constructor
|
|
84
81
|
|
|
@@ -86,56 +83,50 @@ class Prefix {
|
|
|
86
83
|
* Returns the value for the current prefix object
|
|
87
84
|
* @return the value for the prefix object with the specified code
|
|
88
85
|
* */
|
|
89
|
-
|
|
90
|
-
|
|
91
86
|
getValue() {
|
|
92
87
|
return this.value_;
|
|
93
88
|
}
|
|
89
|
+
|
|
94
90
|
/**
|
|
95
91
|
* Returns the prefix code for the current prefix object
|
|
96
92
|
* @return the code for the current prefix object
|
|
97
93
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
94
|
getCode() {
|
|
101
95
|
return this.code_;
|
|
102
96
|
}
|
|
97
|
+
|
|
103
98
|
/**
|
|
104
99
|
* Returns the case-insensitive code for the current prefix object
|
|
105
100
|
* @return the case_insensitive code for the current prefix object
|
|
106
101
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
102
|
getCiCode() {
|
|
110
103
|
return this.ciCode_;
|
|
111
104
|
}
|
|
105
|
+
|
|
112
106
|
/**
|
|
113
107
|
* Returns the prefix name for the current prefix object
|
|
114
108
|
* @return the name for the current prefix object
|
|
115
109
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
110
|
getName() {
|
|
119
111
|
return this.name_;
|
|
120
112
|
}
|
|
113
|
+
|
|
121
114
|
/**
|
|
122
115
|
* Returns the print symbol for the current prefix object
|
|
123
116
|
* @return the print symbol for the current prefix object
|
|
124
117
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
118
|
getPrintSymbol() {
|
|
128
119
|
return this.printSymbol_;
|
|
129
120
|
}
|
|
121
|
+
|
|
130
122
|
/**
|
|
131
123
|
* Returns the exponent for the current prefix object
|
|
132
124
|
* @return the exponent for the current prefix object
|
|
133
125
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
126
|
getExp() {
|
|
137
127
|
return this.exp_;
|
|
138
128
|
}
|
|
129
|
+
|
|
139
130
|
/**
|
|
140
131
|
* Provides way to tell if one prefix equals another. The second prefix
|
|
141
132
|
* must match all attribute values.
|
|
@@ -143,14 +134,9 @@ class Prefix {
|
|
|
143
134
|
* @param prefix2 prefix object to check for a match
|
|
144
135
|
* @return true for a match; false if one or more attributes don't match
|
|
145
136
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
137
|
equals(prefix2) {
|
|
149
138
|
return this.code_ === prefix2.code_ && this.ciCode_ === prefix2.ciCode_ && this.name_ === prefix2.name_ && this.printSymbol_ === prefix2.printSymbol_ && this.value_ === prefix2.value_ && this.exp_ === prefix2.exp_;
|
|
150
139
|
}
|
|
151
|
-
|
|
152
140
|
} // end Prefix class
|
|
153
|
-
|
|
154
|
-
|
|
155
141
|
exports.Prefix = Prefix;
|
|
156
142
|
//# sourceMappingURL=prefix.js.map
|
package/source-cjs/prefix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"prefix.js","names":["Ucum","require","Prefix","constructor","attrs","undefined","Error","code_","ciCode_","name_","printSymbol_","value_","parseFloat","exp_","getValue","getCode","getCiCode","getName","getPrintSymbol","getExp","equals","prefix2","exports"],"sources":["../source/prefix.js"],"sourcesContent":["/**\n * Prefix objects are defined in this file.\n */\n\n/**\n * This class implements the prefix object. Prefixes are used as multipliers\n * for units, e.g., km for kilometers\n *\n * @author Lee Mericle, based on java version by Gunther Schadow\n *\n */\nvar Ucum = require('./config.js');\n\nexport class Prefix {\n\n /**\n * Creates a single prefix object.\n *\n * @param attrs a hash of the values to use in creating the prefix object.\n * They should be:\n * code_ - which is the case-sensitive code used for the prefix,\n * e.g., k for kilo\n * ciCode_ - which is the case-insensitive code used for the prefix,\n * e.g., K for kilo\n * name_ - which is the name of the prefix, e.g., kilo\n * printSymbol_ - which is the print symbol for the prefix, e.g., k for kilo\n * value_ - which is teh value to use in multiplying the magnitude of\n * a unit, e.g., for a prefix of c the value will be .01.\n * exp_ - which is the exponent used to get the value. For decimal based\n * prefixes the base is 10 and the exp_ is applied to 10, e.g., for a\n * prefix of c, the exponent will be -2. For prefixes that are not\n * decimal based, this will be null (but must not be undefined).\n *\n * @throws an error if the not all required parameters are provided\n */\n constructor(attrs) {\n\n if (attrs['code_'] === undefined || attrs['code_'] === null ||\n attrs['name_'] === undefined || attrs['name_'] === null ||\n attrs['value_'] === undefined || attrs['value_'] === null ||\n attrs['exp_'] === undefined) {\n throw(new Error('Prefix constructor called missing one or more parameters. ' +\n 'Prefix codes (cs or ci), name, value and exponent must all be specified ' +\n 'and all but the exponent must not be null.'));\n }\n\n /**\n * The prefix code, e.g., k for kilo. This should be the case-sensitive\n * code. Since there's no way to check to see if it's the case-sensitive\n * one as opposed to the case-insensitive one (because although\n * case-insensitive codes all seem to be uppercase, some case-sensitive\n * codes are also all uppercase), we'll just have to believe that the\n * right one was passed in.\n */\n this.code_ = attrs['code_'];\n\n /**\n * The case-insensitive code, e.g., K for kilo\n */\n this.ciCode_ = attrs['ciCode_'];\n\n /**\n * The prefix name, e.g., kilo\n */\n this.name_ = attrs['name_'];\n\n /**\n * The printSymbol for the prefix, e.g., k for kilo\n */\n this.printSymbol_ = attrs['printSymbol_'];\n\n /**\n * The value to use in multiplying the magnitude of a unit\n */\n if (typeof attrs['value_'] === 'string')\n this.value_ = parseFloat(attrs['value_']);\n else\n this.value_ = attrs['value_'] ;\n\n /**\n * The exponent used to create the value from 10. For prefixes that are\n * not based on 10, this will be null.\n */\n this.exp_ = attrs['exp_'] ;\n\n } // end constructor\n\n\n /**\n * Returns the value for the current prefix object\n * @return the value for the prefix object with the specified code\n * */\n getValue() {\n return this.value_;\n }\n\n\n /**\n * Returns the prefix code for the current prefix object\n * @return the code for the current prefix object\n */\n getCode() {\n return this.code_;\n }\n\n\n /**\n * Returns the case-insensitive code for the current prefix object\n * @return the case_insensitive code for the current prefix object\n */\n getCiCode() {\n return this.ciCode_;\n }\n\n\n /**\n * Returns the prefix name for the current prefix object\n * @return the name for the current prefix object\n */\n getName() {\n return this.name_;\n }\n\n\n /**\n * Returns the print symbol for the current prefix object\n * @return the print symbol for the current prefix object\n */\n getPrintSymbol() {\n return this.printSymbol_;\n }\n\n\n /**\n * Returns the exponent for the current prefix object\n * @return the exponent for the current prefix object\n */\n getExp() {\n return this.exp_;\n }\n\n\n /**\n * Provides way to tell if one prefix equals another. The second prefix\n * must match all attribute values.\n *\n * @param prefix2 prefix object to check for a match\n * @return true for a match; false if one or more attributes don't match\n */\n equals(prefix2) {\n return this.code_ === prefix2.code_ &&\n this.ciCode_ === prefix2.ciCode_ &&\n this.name_ === prefix2.name_ &&\n this.printSymbol_ === prefix2.printSymbol_ &&\n this.value_ === prefix2.value_ &&\n this.exp_ === prefix2.exp_ ;\n }\n} // end Prefix class\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,IAAI,GAAGC,OAAO,CAAC,aAAa,CAAC;AAE1B,MAAMC,MAAM,CAAC;EAElB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,KAAK,EAAE;IAEjB,IAAIA,KAAK,CAAC,OAAO,CAAC,KAAKC,SAAS,IAAID,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,IACvDA,KAAK,CAAC,OAAO,CAAC,KAAKC,SAAS,IAAID,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,IACvDA,KAAK,CAAC,QAAQ,CAAC,KAAKC,SAAS,IAAID,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,IACzDA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,IAAI;EAClB;;EAGA;AACF;AACA;AACA;AACA;AACA;AACA;EACEO,MAAMA,CAACC,OAAO,EAAE;IACd,OAAO,IAAI,CAACd,KAAK,KAAKc,OAAO,CAACd,KAAK,IAC3B,IAAI,CAACC,OAAO,KAAKa,OAAO,CAACb,OAAO,IAChC,IAAI,CAACC,KAAK,KAAKY,OAAO,CAACZ,KAAK,IAC5B,IAAI,CAACC,YAAY,KAAKW,OAAO,CAACX,YAAY,IAC1C,IAAI,CAACC,MAAM,KAAKU,OAAO,CAACV,MAAM,IAC9B,IAAI,CAACE,IAAI,KAAKQ,OAAO,CAACR,IAAI;EACpC;AACF,CAAC,CAAC;AAAAS,OAAA,CAAApB,MAAA,GAAAA,MAAA"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PrefixTables = exports.PrefixTablesFactory = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* The tables of defined prefixes is defined in this file.
|
|
10
9
|
*/
|
|
@@ -28,35 +27,32 @@ class PrefixTablesFactory {
|
|
|
28
27
|
this.byCode_ = {};
|
|
29
28
|
this.byValue_ = {};
|
|
30
29
|
}
|
|
30
|
+
|
|
31
31
|
/**
|
|
32
32
|
* Provides the number of prefix objects in each table
|
|
33
33
|
* @returns count of the number of prefix objects in each table
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
35
|
prefixCount() {
|
|
38
36
|
return Object.keys(this.byCode_).length;
|
|
39
37
|
}
|
|
38
|
+
|
|
40
39
|
/**
|
|
41
40
|
* This is used to get all prefix objects by value. Currently it is used
|
|
42
41
|
* to create a csv file with all prefixes and units.
|
|
43
42
|
* @returns csv string containing all prefix objects, ordered by value.
|
|
44
43
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
44
|
allPrefixesByValue() {
|
|
48
45
|
let prefixBuff = '';
|
|
49
|
-
let pList = Object.keys(this.byValue_);
|
|
50
|
-
|
|
46
|
+
let pList = Object.keys(this.byValue_);
|
|
47
|
+
//pList.sort() ;
|
|
51
48
|
let pLen = pList.length;
|
|
52
|
-
|
|
53
49
|
for (let p = 0; p < pLen; p++) {
|
|
54
50
|
let pfx = this.getPrefixByValue(pList[p]);
|
|
55
51
|
prefixBuff += pfx.code_ + ',' + pfx.name_ + ',,' + pfx.value_ + '\r\n';
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
return prefixBuff;
|
|
59
54
|
}
|
|
55
|
+
|
|
60
56
|
/**
|
|
61
57
|
* This is used to get all prefix objects. Currently it is used
|
|
62
58
|
* to get the objects to write to the json ucum definitions file
|
|
@@ -65,31 +61,27 @@ class PrefixTablesFactory {
|
|
|
65
61
|
*
|
|
66
62
|
* @returns an array containing all prefix objects, ordered by code.
|
|
67
63
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
64
|
allPrefixesByCode() {
|
|
71
65
|
let prefixList = [];
|
|
72
66
|
let pList = Object.keys(this.byCode_);
|
|
73
67
|
pList.sort();
|
|
74
68
|
let pLen = pList.length;
|
|
75
|
-
|
|
76
69
|
for (let p = 0; p < pLen; p++) {
|
|
77
70
|
prefixList.push(this.getPrefixByCode(pList[p]));
|
|
78
71
|
}
|
|
79
|
-
|
|
80
72
|
return prefixList;
|
|
81
73
|
}
|
|
74
|
+
|
|
82
75
|
/**
|
|
83
76
|
* Adds a prefix object to the tables
|
|
84
77
|
*
|
|
85
78
|
* @param prefixObj the object to be added to the tables
|
|
86
79
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
80
|
add(prefixObj) {
|
|
90
81
|
this.byCode_[prefixObj.getCode()] = prefixObj;
|
|
91
82
|
this.byValue_[prefixObj.getValue()] = prefixObj;
|
|
92
83
|
}
|
|
84
|
+
|
|
93
85
|
/**
|
|
94
86
|
* Tests whether a prefix object is found for a specified code. This
|
|
95
87
|
* is used to determine whether or not a prefix object has been created
|
|
@@ -99,39 +91,33 @@ class PrefixTablesFactory {
|
|
|
99
91
|
* @return boolean indicating whether or not a prefix object was found
|
|
100
92
|
* for the specified code
|
|
101
93
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
94
|
isDefined(code) {
|
|
105
95
|
return this.byCode_[code] !== null && this.byCode_[code] !== undefined;
|
|
106
96
|
}
|
|
97
|
+
|
|
107
98
|
/**
|
|
108
99
|
* Obtains a prefix object for a specified code.
|
|
109
100
|
*
|
|
110
101
|
* @param code the code to be used to find the prefix object
|
|
111
102
|
* @return the prefix object found, or null if nothing was found
|
|
112
103
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
104
|
getPrefixByCode(code) {
|
|
116
105
|
return this.byCode_[code];
|
|
117
106
|
}
|
|
107
|
+
|
|
118
108
|
/**
|
|
119
109
|
* Obtains a prefix object for a specified value.
|
|
120
110
|
*
|
|
121
111
|
* @param value the value to be used to find the prefix object
|
|
122
112
|
* @return the prefix object found, or null if nothing was found
|
|
123
113
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
114
|
getPrefixByValue(value) {
|
|
127
115
|
return this.byValue_[value];
|
|
128
116
|
}
|
|
129
|
-
|
|
130
117
|
} // end PrefixTablesFactory class
|
|
118
|
+
|
|
131
119
|
// Create a singleton instance and (to preserve the existing API) an object that
|
|
132
120
|
// provides that instance via getInstance().
|
|
133
|
-
|
|
134
|
-
|
|
135
121
|
exports.PrefixTablesFactory = PrefixTablesFactory;
|
|
136
122
|
var prefixTablesInstance = new PrefixTablesFactory();
|
|
137
123
|
const PrefixTables = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,CAA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Ed,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;AAAAD,OAAA,CAAAE,YAAA,GAAAA,YAAA"}
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* This class manages the special functions used by some units.
|
|
10
9
|
*
|
|
11
10
|
* @author Lee Mericle, based on java version by Gunther Schadow
|
|
12
11
|
*
|
|
13
12
|
*/
|
|
13
|
+
|
|
14
14
|
class UcumFunctions {
|
|
15
15
|
/**
|
|
16
16
|
* Constructor
|
|
@@ -20,9 +20,10 @@ class UcumFunctions {
|
|
|
20
20
|
*/
|
|
21
21
|
constructor() {
|
|
22
22
|
// Create the hash containing the function pairs
|
|
23
|
-
this.funcs = {};
|
|
24
|
-
// where kelvin is the base unit for temperature
|
|
23
|
+
this.funcs = {};
|
|
25
24
|
|
|
25
|
+
// Celsius - convert to Celsius from kelvin and from Celsius to kelvin
|
|
26
|
+
// where kelvin is the base unit for temperature
|
|
26
27
|
this.funcs['cel'] = {
|
|
27
28
|
cnvTo: function (x) {
|
|
28
29
|
return x - 273.15;
|
|
@@ -30,9 +31,10 @@ class UcumFunctions {
|
|
|
30
31
|
cnvFrom: function (x) {
|
|
31
32
|
return x + 273.15;
|
|
32
33
|
}
|
|
33
|
-
};
|
|
34
|
-
// kelvin - which is the base unit for temperature
|
|
34
|
+
};
|
|
35
35
|
|
|
36
|
+
// Fahrenheit - convert to Fahrenheit from kelvin and from Fahrenheit to
|
|
37
|
+
// kelvin - which is the base unit for temperature
|
|
36
38
|
this.funcs['degf'] = {
|
|
37
39
|
cnvTo: function (x) {
|
|
38
40
|
return x - 459.67;
|
|
@@ -40,13 +42,14 @@ class UcumFunctions {
|
|
|
40
42
|
cnvFrom: function (x) {
|
|
41
43
|
return x + 459.67;
|
|
42
44
|
}
|
|
43
|
-
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Reaumur - convert between Reaumur and Kelvin. Because of the way the
|
|
44
48
|
// calling code in the Units class is set up (in the convertFrom method),
|
|
45
49
|
// what is given here as the convertTo function is actually the convert
|
|
46
50
|
// from method and vice versa.
|
|
47
51
|
//this.funcs['degre'] = {cnvTo : function(x){return x + 273.15;},
|
|
48
52
|
// cnvFrom : function(x){return x - 273.15;}};
|
|
49
|
-
|
|
50
53
|
this.funcs['degre'] = {
|
|
51
54
|
cnvTo: function (x) {
|
|
52
55
|
return x - 273.15;
|
|
@@ -54,9 +57,10 @@ class UcumFunctions {
|
|
|
54
57
|
cnvFrom: function (x) {
|
|
55
58
|
return x + 273.15;
|
|
56
59
|
}
|
|
57
|
-
};
|
|
58
|
-
// where a mole is an amount of a substance (a count of particles)
|
|
60
|
+
};
|
|
59
61
|
|
|
62
|
+
// pH - convert to pH from moles per liter and from moles per liter to pH
|
|
63
|
+
// where a mole is an amount of a substance (a count of particles)
|
|
60
64
|
this.funcs['ph'] = {
|
|
61
65
|
cnvTo: function (x) {
|
|
62
66
|
return -Math.log(x) / Math.LN10;
|
|
@@ -64,9 +68,10 @@ class UcumFunctions {
|
|
|
64
68
|
cnvFrom: function (x) {
|
|
65
69
|
return Math.pow(10, -x);
|
|
66
70
|
}
|
|
67
|
-
};
|
|
68
|
-
// and 2ln - two times the natural logarithm
|
|
71
|
+
};
|
|
69
72
|
|
|
73
|
+
// ln - natural logarithm (base e 2.71828) - apply (cnvTo) and invert (cnvFrom)
|
|
74
|
+
// and 2ln - two times the natural logarithm
|
|
70
75
|
this.funcs['ln'] = {
|
|
71
76
|
cnvTo: function (x) {
|
|
72
77
|
return Math.log(x);
|
|
@@ -82,8 +87,9 @@ class UcumFunctions {
|
|
|
82
87
|
cnvFrom: function (x) {
|
|
83
88
|
return Math.exp(x / 2);
|
|
84
89
|
}
|
|
85
|
-
};
|
|
90
|
+
};
|
|
86
91
|
|
|
92
|
+
// lg - the decadic logarithm (base 10)
|
|
87
93
|
this.funcs['lg'] = {
|
|
88
94
|
cnvTo: function (x) {
|
|
89
95
|
return Math.log(x) / Math.LN10;
|
|
@@ -107,8 +113,8 @@ class UcumFunctions {
|
|
|
107
113
|
cnvFrom: function (x) {
|
|
108
114
|
return Math.pow(10, x / 20);
|
|
109
115
|
}
|
|
110
|
-
};
|
|
111
|
-
|
|
116
|
+
};
|
|
117
|
+
// The plain text ucum units file uses '2lg'
|
|
112
118
|
this.funcs['2lg'] = {
|
|
113
119
|
cnvTo: function (x) {
|
|
114
120
|
return 2 * Math.log(x) / Math.LN10;
|
|
@@ -116,10 +122,11 @@ class UcumFunctions {
|
|
|
116
122
|
cnvFrom: function (x) {
|
|
117
123
|
return Math.pow(10, x / 2);
|
|
118
124
|
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
this.funcs['lgtimes2'] = this.funcs['2lg'];
|
|
125
|
+
};
|
|
126
|
+
// The xml essence ucum file uses lgTimes2
|
|
127
|
+
this.funcs['lgtimes2'] = this.funcs['2lg'];
|
|
122
128
|
|
|
129
|
+
// ld - dual logarithm (base 2)
|
|
123
130
|
this.funcs['ld'] = {
|
|
124
131
|
cnvTo: function (x) {
|
|
125
132
|
return Math.log(x) / Math.LN2;
|
|
@@ -127,8 +134,9 @@ class UcumFunctions {
|
|
|
127
134
|
cnvFrom: function (x) {
|
|
128
135
|
return Math.pow(2, x);
|
|
129
136
|
}
|
|
130
|
-
};
|
|
137
|
+
};
|
|
131
138
|
|
|
139
|
+
// tan - tangent
|
|
132
140
|
this.funcs['100tan'] = {
|
|
133
141
|
cnvTo: function (x) {
|
|
134
142
|
return Math.tan(x) * 100;
|
|
@@ -136,10 +144,11 @@ class UcumFunctions {
|
|
|
136
144
|
cnvFrom: function (x) {
|
|
137
145
|
return Math.atan(x / 100);
|
|
138
146
|
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
this.funcs['tanTimes100'] = this.funcs['100tan'];
|
|
147
|
+
};
|
|
148
|
+
// the xml essence ucum file uses both 100tan and tanTimes100
|
|
149
|
+
this.funcs['tanTimes100'] = this.funcs['100tan'];
|
|
142
150
|
|
|
151
|
+
// sqrt - square root
|
|
143
152
|
this.funcs['sqrt'] = {
|
|
144
153
|
cnvTo: function (x) {
|
|
145
154
|
return Math.sqrt(x);
|
|
@@ -147,8 +156,9 @@ class UcumFunctions {
|
|
|
147
156
|
cnvFrom: function (x) {
|
|
148
157
|
return x * x;
|
|
149
158
|
}
|
|
150
|
-
};
|
|
159
|
+
};
|
|
151
160
|
|
|
161
|
+
// inv - inverse
|
|
152
162
|
this.funcs['inv'] = {
|
|
153
163
|
cnvTo: function (x) {
|
|
154
164
|
return 1.0 / x;
|
|
@@ -156,8 +166,9 @@ class UcumFunctions {
|
|
|
156
166
|
cnvFrom: function (x) {
|
|
157
167
|
return 1.0 / x;
|
|
158
168
|
}
|
|
159
|
-
};
|
|
169
|
+
};
|
|
160
170
|
|
|
171
|
+
// homeopathic potency functions
|
|
161
172
|
this.funcs['hpX'] = {
|
|
162
173
|
cnvTo: function (x) {
|
|
163
174
|
return -this.funcs['lg'](x);
|
|
@@ -199,14 +210,13 @@ class UcumFunctions {
|
|
|
199
210
|
* @return the function with the specified name
|
|
200
211
|
* @throws an error message if the function is not found
|
|
201
212
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
213
|
forName(fname) {
|
|
205
214
|
fname = fname.toLowerCase();
|
|
206
215
|
let f = this.funcs[fname];
|
|
207
216
|
if (f === null) throw new Error(`Requested function ${fname} is not defined`);
|
|
208
217
|
return f;
|
|
209
218
|
}
|
|
219
|
+
|
|
210
220
|
/**
|
|
211
221
|
* Returns a flag indicating whether or not the function has been
|
|
212
222
|
* defined.
|
|
@@ -214,18 +224,11 @@ class UcumFunctions {
|
|
|
214
224
|
* @param fname name of the function in question
|
|
215
225
|
* @return true if it has been defined; false if not
|
|
216
226
|
*/
|
|
217
|
-
|
|
218
|
-
|
|
219
227
|
isDefined(fname) {
|
|
220
228
|
fname = fname.toLowerCase();
|
|
221
229
|
return this.funcs[fname] !== null;
|
|
222
230
|
}
|
|
223
|
-
|
|
224
231
|
} // end of UcumFunctions class
|
|
225
|
-
|
|
226
|
-
|
|
227
232
|
var _default = new UcumFunctions(); // one singleton instance
|
|
228
|
-
|
|
229
|
-
|
|
230
233
|
exports.default = _default;
|
|
231
234
|
//# sourceMappingURL=ucumFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/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"],"mappings":";;;;;;;AAAA;;;;;;AAOA,MAAMA,aAAN,CAAoB;AAElB;;;;;;AAMAC,EAAAA,WAAW,GAAG;AAEZ;AACA,SAAKC,KAAL,GAAa,EAAb,CAHY,CAKZ;AACA;;AACA,SAAKA,KAAL,CAAW,KAAX,IAAoB;AAACC,MAAAA,KAAK,EAAK,UAASC,CAAT,EAAW;AAAC,eAAOA,CAAC,GAAG,MAAX;AAAmB,OAA1C;AACFC,MAAAA,OAAO,EAAG,UAASD,CAAT,EAAW;AAAC,eAAOA,CAAC,GAAG,MAAX;AAAmB;AADvC,KAApB,CAPY,CAUZ;AACA;;AACA,SAAKF,KAAL,CAAW,MAAX,IAAqB;AAACC,MAAAA,KAAK,EAAK,UAASC,CAAT,EAAW;AAAC,eAAOA,CAAC,GAAG,MAAX;AAAmB,OAA1C;AACFC,MAAAA,OAAO,EAAG,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AX,EAAiB,KAAjB,CAA9B;AAAuD,OAD7D;AAEFG,MAAAA,OAAO,EAAG,UAASD,CAAT,EAAW;AAAC,eAAOE,IAAI,CAACG,GAAL,CAAS,KAAT,EAAgB,CAACL,CAAjB,CAAP;AAA4B;AAFhD,KAApB;AAID,GA3FiB,CA2FhB;;AAGF;;;;;;;;;AAOAY,EAAAA,OAAO,CAACC,KAAD,EAAQ;AACbA,IAAAA,KAAK,GAAGA,KAAK,CAACC,WAAN,EAAR;AAEA,QAAIC,CAAC,GAAG,KAAKjB,KAAL,CAAWe,KAAX,CAAR;AACA,QAAIE,CAAC,KAAK,IAAV,EACE,MAAM,IAAIC,KAAJ,CAAW,sBAAqBH,KAAM,iBAAtC,CAAN;AACF,WAAOE,CAAP;AACD;AAGD;;;;;;;;;AAOAE,EAAAA,SAAS,CAACJ,KAAD,EAAQ;AACfA,IAAAA,KAAK,GAAGA,KAAK,CAACC,WAAN,EAAR;AACA,WAAO,KAAKhB,KAAL,CAAWe,KAAX,MAAsB,IAA7B;AACD;;AAzHiB,C,CA2HlB;;;eAEa,IAAIjB,aAAJ,E,EAAqB","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"],"file":"ucumFunctions.js"}
|
|
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,CAASC,CAAC,EAA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AIC,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"}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isNumericString = isNumericString;
|
|
7
7
|
exports.isIntegerUnit = isIntegerUnit;
|
|
8
8
|
exports.getSynonyms = getSynonyms;
|
|
9
|
-
|
|
10
9
|
/**
|
|
11
10
|
* Internal utilities used by multiple UCUM classes. For example,
|
|
12
11
|
* isNumericString is used by both the UnitString and UcumLhcUtils
|
|
@@ -25,7 +24,9 @@ exports.getSynonyms = getSynonyms;
|
|
|
25
24
|
* @author Lee Mericle, based on java version by Gunther Schadow
|
|
26
25
|
*
|
|
27
26
|
*/
|
|
27
|
+
|
|
28
28
|
var UnitTables = require('./unitTables.js').UnitTables;
|
|
29
|
+
|
|
29
30
|
/**
|
|
30
31
|
* This function tests a string to see if it contains only numbers (digits,
|
|
31
32
|
* a period, leading - or +). This code was taken from a stackoverflow
|
|
@@ -35,11 +36,8 @@ var UnitTables = require('./unitTables.js').UnitTables;
|
|
|
35
36
|
* @params theString
|
|
36
37
|
* @returns true if the string contains only numbers; false otherwise
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
39
|
function isNumericString(theString) {
|
|
41
40
|
let num = "" + theString; //coerce num to be a string
|
|
42
|
-
|
|
43
41
|
return !isNaN(num) && !isNaN(parseFloat(num));
|
|
44
42
|
} // end isNumericString
|
|
45
43
|
|
|
@@ -52,11 +50,10 @@ function isNumericString(theString) {
|
|
|
52
50
|
* it is positive, but you can't measure anything in units of zero.
|
|
53
51
|
* @param str the string to check
|
|
54
52
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
53
|
function isIntegerUnit(str) {
|
|
58
54
|
return /^\d+$/.test(str);
|
|
59
55
|
}
|
|
56
|
+
|
|
60
57
|
/**
|
|
61
58
|
* This method accepts a term and looks for units that include it as
|
|
62
59
|
* a synonym - or that include the term in its name.
|
|
@@ -72,14 +69,13 @@ function isIntegerUnit(str) {
|
|
|
72
69
|
* the unit's csCode_, the unit's name_, and the unit's guidance_
|
|
73
70
|
*
|
|
74
71
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
72
|
function getSynonyms(theSyn) {
|
|
78
73
|
let retObj = {};
|
|
79
74
|
let utab = UnitTables.getInstance();
|
|
80
75
|
let resp = {};
|
|
81
|
-
resp = utab.getUnitBySynonym(theSyn);
|
|
76
|
+
resp = utab.getUnitBySynonym(theSyn);
|
|
82
77
|
|
|
78
|
+
// If we didn't get any units, transfer the status and message
|
|
83
79
|
if (!resp['units']) {
|
|
84
80
|
retObj['status'] = resp['status'];
|
|
85
81
|
retObj['msg'] = resp['msg'];
|
|
@@ -87,7 +83,6 @@ function getSynonyms(theSyn) {
|
|
|
87
83
|
retObj['status'] = 'succeeded';
|
|
88
84
|
let aLen = resp['units'].length;
|
|
89
85
|
retObj['units'] = [];
|
|
90
|
-
|
|
91
86
|
for (let a = 0; a < aLen; a++) {
|
|
92
87
|
let theUnit = resp['units'][a];
|
|
93
88
|
retObj['units'][a] = {
|
|
@@ -96,10 +91,7 @@ function getSynonyms(theSyn) {
|
|
|
96
91
|
'guidance': theUnit.guidance_
|
|
97
92
|
};
|
|
98
93
|
} // end do for all units returned
|
|
99
|
-
|
|
100
94
|
} // end if we got a units list
|
|
101
|
-
|
|
102
|
-
|
|
103
95
|
return retObj;
|
|
104
96
|
} // end getSynonyms
|
|
105
97
|
//# sourceMappingURL=ucumInternalUtils.js.map
|