@sswroom/sswr 1.6.4 → 1.6.5

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/unit.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import * as math from "./math.js";
2
2
 
3
- export class UnitInfo
4
- {
5
- constructor(unit, symbol, name, ratio, scale)
6
- {
3
+ export class UnitInfo {
4
+ /**
5
+ * @param {number} unit
6
+ * @param {string} symbol
7
+ * @param {string} name
8
+ * @param {number} ratio
9
+ * @param {number | undefined} [scale]
10
+ */
11
+ constructor(unit, symbol, name, ratio, scale) {
7
12
  this.unit = unit;
8
13
  this.symbol = symbol;
9
14
  this.name = name;
@@ -12,45 +17,49 @@ export class UnitInfo
12
17
  }
13
18
  }
14
19
 
15
- export class Acceleration
16
- {
20
+ export class Acceleration {
17
21
  static Unit = {
18
22
  METER_PER_SECOND_SQUARED: 1,
19
23
  STANDARD_GRAVITY: 2
20
24
  };
21
25
 
22
- static getUnitInfo(u)
23
- {
24
- switch (u)
25
- {
26
- case Acceleration.Unit.METER_PER_SECOND_SQUARED:
27
- return new UnitInfo(u, "m/s^2", "Meter Per Second Squared", 1);
28
- case Acceleration.Unit.STANDARD_GRAVITY:
29
- return new UnitInfo(u, "g", "Gravity", 9.80665);
26
+ /**
27
+ * @param {number} u
28
+ */
29
+ static getUnitInfo(u) {
30
+ switch (u) {
31
+ case Acceleration.Unit.METER_PER_SECOND_SQUARED:
32
+ return new UnitInfo(u, "m/s^2", "Meter Per Second Squared", 1);
33
+ case Acceleration.Unit.STANDARD_GRAVITY:
34
+ return new UnitInfo(u, "g", "Gravity", 9.80665);
30
35
  }
31
36
  return null;
32
37
  }
33
38
 
34
- static getUnitRatio(u)
35
- {
36
- switch (u)
37
- {
38
- case Acceleration.Unit.METER_PER_SECOND_SQUARED:
39
- return 1.0;
40
- case Acceleration.Unit.STANDARD_GRAVITY:
41
- return 9.80665;
39
+ /**
40
+ * @param {number} u
41
+ */
42
+ static getUnitRatio(u) {
43
+ switch (u) {
44
+ case Acceleration.Unit.METER_PER_SECOND_SQUARED:
45
+ return 1.0;
46
+ case Acceleration.Unit.STANDARD_GRAVITY:
47
+ return 9.80665;
42
48
  }
43
49
  return 1.0;
44
50
  }
45
-
46
- static convert(fromUnit, toUnit, fromValue)
47
- {
51
+
52
+ /**
53
+ * @param {number} fromUnit
54
+ * @param {number} toUnit
55
+ * @param {number} fromValue
56
+ */
57
+ static convert(fromUnit, toUnit, fromValue) {
48
58
  return fromValue * Acceleration.getUnitRatio(fromUnit) / Acceleration.getUnitRatio(toUnit);
49
59
  }
50
60
  }
51
61
 
52
- export class Angle
53
- {
62
+ export class Angle {
54
63
  static Unit = {
55
64
  RADIAN: 1,
56
65
  GRADIAN: 2,
@@ -62,94 +71,104 @@ export class Angle
62
71
  MICROARCSECOND: 8
63
72
  };
64
73
 
65
- static getUnitInfo(u)
66
- {
67
- switch (u)
68
- {
69
- case Angle.Unit.RADIAN:
70
- return new UnitInfo(u, "rad", "Radian", 1);
71
- case Angle.Unit.GRADIAN:
72
- return new UnitInfo(u, "grad", "Gradian", Math.PI / 200.0);
73
- case Angle.Unit.TURN:
74
- return new UnitInfo(u, "", "Turns", Math.PI * 2.0);
75
- case Angle.Unit.DEGREE:
76
- return new UnitInfo(u, "°", "Degree", Math.PI / 180.0);
77
- case Angle.Unit.ARCMINUTE:
78
- return new UnitInfo(u, "′", "Arcminute", Math.PI / 10800.0);
79
- case Angle.Unit.ARCSECOND:
80
- return new UnitInfo(u, "″", "Arcsecond", Math.PI / 648000.0);
81
- case Angle.Unit.MILLIARCSECOND:
82
- return new UnitInfo(u, "mas", "Milliarcsecond", Math.PI / 648000000.0);
83
- case Angle.Unit.MICROARCSECOND:
84
- return new UnitInfo(u, "μas", "Microarcsecond", Math.PI / 648000000000.0);
74
+ /**
75
+ * @param {number} u
76
+ */
77
+ static getUnitInfo(u) {
78
+ switch (u) {
79
+ case Angle.Unit.RADIAN:
80
+ return new UnitInfo(u, "rad", "Radian", 1);
81
+ case Angle.Unit.GRADIAN:
82
+ return new UnitInfo(u, "grad", "Gradian", Math.PI / 200.0);
83
+ case Angle.Unit.TURN:
84
+ return new UnitInfo(u, "", "Turns", Math.PI * 2.0);
85
+ case Angle.Unit.DEGREE:
86
+ return new UnitInfo(u, "°", "Degree", Math.PI / 180.0);
87
+ case Angle.Unit.ARCMINUTE:
88
+ return new UnitInfo(u, "′", "Arcminute", Math.PI / 10800.0);
89
+ case Angle.Unit.ARCSECOND:
90
+ return new UnitInfo(u, "″", "Arcsecond", Math.PI / 648000.0);
91
+ case Angle.Unit.MILLIARCSECOND:
92
+ return new UnitInfo(u, "mas", "Milliarcsecond", Math.PI / 648000000.0);
93
+ case Angle.Unit.MICROARCSECOND:
94
+ return new UnitInfo(u, "μas", "Microarcsecond", Math.PI / 648000000000.0);
85
95
  }
86
96
  return null;
87
97
  }
88
98
 
89
- static getUnitRatio(u)
90
- {
91
- switch (u)
92
- {
93
- case Angle.Unit.RADIAN:
94
- return 1;
95
- case Angle.Unit.GRADIAN:
96
- return Math.PI / 200.0;
97
- case Angle.Unit.TURN:
98
- return Math.PI * 2.0;
99
- case Angle.Unit.DEGREE:
100
- return Math.PI / 180.0;
101
- case Angle.Unit.ARCMINUTE:
102
- return Math.PI / 10800.0;
103
- case Angle.Unit.ARCSECOND:
104
- return Math.PI / 648000.0;
105
- case Angle.Unit.MILLIARCSECOND:
106
- return Math.PI / 648000000.0;
107
- case Angle.Unit.MICROARCSECOND:
108
- return Math.PI / 648000000000.0;
99
+ /**
100
+ * @param {number} u
101
+ */
102
+ static getUnitRatio(u) {
103
+ switch (u) {
104
+ case Angle.Unit.RADIAN:
105
+ return 1;
106
+ case Angle.Unit.GRADIAN:
107
+ return Math.PI / 200.0;
108
+ case Angle.Unit.TURN:
109
+ return Math.PI * 2.0;
110
+ case Angle.Unit.DEGREE:
111
+ return Math.PI / 180.0;
112
+ case Angle.Unit.ARCMINUTE:
113
+ return Math.PI / 10800.0;
114
+ case Angle.Unit.ARCSECOND:
115
+ return Math.PI / 648000.0;
116
+ case Angle.Unit.MILLIARCSECOND:
117
+ return Math.PI / 648000000.0;
118
+ case Angle.Unit.MICROARCSECOND:
119
+ return Math.PI / 648000000000.0;
109
120
  }
110
121
  return 1;
111
122
  }
112
123
 
113
- static convert(fromUnit, toUnit, fromValue)
114
- {
124
+ /**
125
+ * @param {number} fromUnit
126
+ * @param {number} toUnit
127
+ * @param {number} fromValue
128
+ */
129
+ static convert(fromUnit, toUnit, fromValue) {
115
130
  return fromValue * Angle.getUnitRatio(fromUnit) / Angle.getUnitRatio(toUnit);
116
131
  }
117
132
  }
118
133
 
119
- export class ApparentPower
120
- {
134
+ export class ApparentPower {
121
135
  static Unit = {
122
136
  VOLT_AMPERE: 1
123
137
  };
124
138
 
125
- static getUnitInfo(u)
126
- {
127
- switch (u)
128
- {
129
- case ApparentPower.Unit.VOLT_AMPERE:
130
- return new UnitInfo(u, "VA", "Volt-Ampere", 1);
139
+ /**
140
+ * @param {number} u
141
+ */
142
+ static getUnitInfo(u) {
143
+ switch (u) {
144
+ case ApparentPower.Unit.VOLT_AMPERE:
145
+ return new UnitInfo(u, "VA", "Volt-Ampere", 1);
131
146
  }
132
147
  return null;
133
148
  }
134
149
 
135
- static getUnitRatio(u)
136
- {
137
- switch (u)
138
- {
139
- case ApparentPower.Unit.VOLT_AMPERE:
140
- return 1;
150
+ /**
151
+ * @param {number} u
152
+ */
153
+ static getUnitRatio(u) {
154
+ switch (u) {
155
+ case ApparentPower.Unit.VOLT_AMPERE:
156
+ return 1;
141
157
  }
142
158
  return 1;
143
159
  }
144
160
 
145
- static convert(fromUnit, toUnit, fromValue)
146
- {
161
+ /**
162
+ * @param {number} fromUnit
163
+ * @param {number} toUnit
164
+ * @param {number} fromValue
165
+ */
166
+ static convert(fromUnit, toUnit, fromValue) {
147
167
  return fromValue * ApparentPower.getUnitRatio(fromUnit) / ApparentPower.getUnitRatio(toUnit);
148
168
  }
149
169
  }
150
170
 
151
- export class Count
152
- {
171
+ export class Count {
153
172
  static Unit = {
154
173
  UNIT: 1,
155
174
  K_UNIT: 2,
@@ -162,174 +181,161 @@ export class Count
162
181
  TI_UNIT: 9
163
182
  };
164
183
 
165
- static getUnitInfo(u)
166
- {
167
- switch (u)
168
- {
169
- case Count.Unit.UNIT:
170
- return new UnitInfo(u, "", "Unit", 1.0);
171
- case Count.Unit.K_UNIT:
172
- return new UnitInfo(u, "K", "Kilo", 1000.0);
173
- case Count.Unit.KI_UNIT:
174
- return new UnitInfo(u, "Ki", "Binary Kilo", 1024.0);
175
- case Count.Unit.M_UNIT:
176
- return new UnitInfo(u, "M", "Mega", 1000000.0);
177
- case Count.Unit.MI_UNIT:
178
- return new UnitInfo(u, "Mi", "Binary Mega", 1048576.0);
179
- case Count.Unit.G_UNIT:
180
- return new UnitInfo(u, "G", "Giga", 1000000000.0);
181
- case Count.Unit.GI_UNIT:
182
- return new UnitInfo(u, "Gi", "Binary Giga", 1073741824.0);
183
- case Count.Unit.T_UNIT:
184
- return new UnitInfo(u, "T", "Tera", 1000000000000.0);
185
- case Count.Unit.TI_UNIT:
186
- return new UnitInfo(u, "Ti", "Binary Tera", 1099511627776.0);
184
+ /**
185
+ * @param {number} u
186
+ */
187
+ static getUnitInfo(u) {
188
+ switch (u) {
189
+ case Count.Unit.UNIT:
190
+ return new UnitInfo(u, "", "Unit", 1.0);
191
+ case Count.Unit.K_UNIT:
192
+ return new UnitInfo(u, "K", "Kilo", 1000.0);
193
+ case Count.Unit.KI_UNIT:
194
+ return new UnitInfo(u, "Ki", "Binary Kilo", 1024.0);
195
+ case Count.Unit.M_UNIT:
196
+ return new UnitInfo(u, "M", "Mega", 1000000.0);
197
+ case Count.Unit.MI_UNIT:
198
+ return new UnitInfo(u, "Mi", "Binary Mega", 1048576.0);
199
+ case Count.Unit.G_UNIT:
200
+ return new UnitInfo(u, "G", "Giga", 1000000000.0);
201
+ case Count.Unit.GI_UNIT:
202
+ return new UnitInfo(u, "Gi", "Binary Giga", 1073741824.0);
203
+ case Count.Unit.T_UNIT:
204
+ return new UnitInfo(u, "T", "Tera", 1000000000000.0);
205
+ case Count.Unit.TI_UNIT:
206
+ return new UnitInfo(u, "Ti", "Binary Tera", 1099511627776.0);
187
207
  }
188
208
  return null;
189
209
  }
190
210
 
191
- static getUnitRatio(u)
192
- {
193
- switch (u)
194
- {
195
- case Count.Unit.UNIT:
196
- return 1.0;
197
- case Count.Unit.K_UNIT:
198
- return 1000.0;
199
- case Count.Unit.KI_UNIT:
200
- return 1024.0;
201
- case Count.Unit.M_UNIT:
202
- return 1000000.0;
203
- case Count.Unit.MI_UNIT:
204
- return 1048576.0;
205
- case Count.Unit.G_UNIT:
206
- return 1000000000.0;
207
- case Count.Unit.GI_UNIT:
208
- return 1073741824.0;
209
- case Count.Unit.T_UNIT:
210
- return 1000000000000.0;
211
- case Count.Unit.TI_UNIT:
212
- return 1099511627776.0;
211
+ /**
212
+ * @param {number} u
213
+ */
214
+ static getUnitRatio(u) {
215
+ switch (u) {
216
+ case Count.Unit.UNIT:
217
+ return 1.0;
218
+ case Count.Unit.K_UNIT:
219
+ return 1000.0;
220
+ case Count.Unit.KI_UNIT:
221
+ return 1024.0;
222
+ case Count.Unit.M_UNIT:
223
+ return 1000000.0;
224
+ case Count.Unit.MI_UNIT:
225
+ return 1048576.0;
226
+ case Count.Unit.G_UNIT:
227
+ return 1000000000.0;
228
+ case Count.Unit.GI_UNIT:
229
+ return 1073741824.0;
230
+ case Count.Unit.T_UNIT:
231
+ return 1000000000000.0;
232
+ case Count.Unit.TI_UNIT:
233
+ return 1099511627776.0;
213
234
  }
214
235
  return 1;
215
236
  }
216
237
 
217
- static convert(fromUnit, toUnit, fromValue)
218
- {
238
+ /**
239
+ * @param {number} fromUnit
240
+ * @param {number} toUnit
241
+ * @param {number} fromValue
242
+ */
243
+ static convert(fromUnit, toUnit, fromValue) {
219
244
  return fromValue * ApparentPower.getUnitRatio(fromUnit) / ApparentPower.getUnitRatio(toUnit);
220
245
  }
221
246
 
222
- static wellFormat(val, nDecimal)
223
- {
247
+ /**
248
+ * @param {number} val
249
+ * @param {number | null} nDecimal
250
+ */
251
+ static wellFormat(val, nDecimal) {
224
252
  if (nDecimal == null || nDecimal < 1)
225
253
  nDecimal = 2;
226
254
  let lval = Math.log10(val);
227
- if (lval < 0)
228
- {
229
- if (lval >= -2)
230
- {
231
- return math.roundToStr(val * 100, nDecimal)+"c";
255
+ if (lval < 0) {
256
+ if (lval >= -2) {
257
+ return math.roundToStr(val * 100, nDecimal) + "c";
232
258
  }
233
- else if (lval >= -3)
234
- {
235
- return math.roundToStr(val * 1000, nDecimal)+"m";
259
+ else if (lval >= -3) {
260
+ return math.roundToStr(val * 1000, nDecimal) + "m";
236
261
  }
237
- else if (lval >= -6)
238
- {
239
- return math.roundToStr(val * 1000000, nDecimal)+"u";
262
+ else if (lval >= -6) {
263
+ return math.roundToStr(val * 1000000, nDecimal) + "u";
240
264
  }
241
- else if (lval >= -9)
242
- {
243
- return math.roundToStr(val * 1.0e9, nDecimal)+"n";
265
+ else if (lval >= -9) {
266
+ return math.roundToStr(val * 1.0e9, nDecimal) + "n";
244
267
  }
245
- else if (lval >= -12)
246
- {
247
- return math.roundToStr(val * 1.0e12, nDecimal)+"p";
268
+ else if (lval >= -12) {
269
+ return math.roundToStr(val * 1.0e12, nDecimal) + "p";
248
270
  }
249
- else if (lval >= -15)
250
- {
251
- return math.roundToStr(val * 1.0e15, nDecimal)+"f";
271
+ else if (lval >= -15) {
272
+ return math.roundToStr(val * 1.0e15, nDecimal) + "f";
252
273
  }
253
- else if (lval >= -18)
254
- {
255
- return math.roundToStr(val * 1.0e18, nDecimal)+"a";
274
+ else if (lval >= -18) {
275
+ return math.roundToStr(val * 1.0e18, nDecimal) + "a";
256
276
  }
257
- else if (lval >= -21)
258
- {
259
- return math.roundToStr(val * 1.0e21, nDecimal)+"z";
277
+ else if (lval >= -21) {
278
+ return math.roundToStr(val * 1.0e21, nDecimal) + "z";
260
279
  }
261
- else
262
- {
263
- return math.roundToStr(val * 1.0e24, nDecimal)+"y";
280
+ else {
281
+ return math.roundToStr(val * 1.0e24, nDecimal) + "y";
264
282
  }
265
283
  }
266
- else if (lval < 3)
267
- {
284
+ else if (lval < 3) {
268
285
  return math.roundToStr(val, nDecimal);
269
286
  }
270
- else if (lval < 6)
271
- {
272
- return math.roundToStr(val / 1.0e3, nDecimal)+"k";
287
+ else if (lval < 6) {
288
+ return math.roundToStr(val / 1.0e3, nDecimal) + "k";
273
289
  }
274
- else if (lval < 9)
275
- {
276
- return math.roundToStr(val / 1.0e6, nDecimal)+"M";
290
+ else if (lval < 9) {
291
+ return math.roundToStr(val / 1.0e6, nDecimal) + "M";
277
292
  }
278
- else if (val < 12)
279
- {
280
- return math.roundToStr(val / 1.0e9, nDecimal)+"G";
293
+ else if (val < 12) {
294
+ return math.roundToStr(val / 1.0e9, nDecimal) + "G";
281
295
  }
282
- else if (val < 15)
283
- {
284
- return math.roundToStr(val / 1.0e12, nDecimal)+"T";
296
+ else if (val < 15) {
297
+ return math.roundToStr(val / 1.0e12, nDecimal) + "T";
285
298
  }
286
- else if (val < 18)
287
- {
288
- return math.roundToStr(val / 1.0e15, nDecimal)+"P";
299
+ else if (val < 18) {
300
+ return math.roundToStr(val / 1.0e15, nDecimal) + "P";
289
301
  }
290
- else if (val < 21)
291
- {
292
- return math.roundToStr(val / 1.0e18, nDecimal)+"E";
302
+ else if (val < 21) {
303
+ return math.roundToStr(val / 1.0e18, nDecimal) + "E";
293
304
  }
294
- else if (val < 24)
295
- {
296
- return math.roundToStr(val / 1.0e21, nDecimal)+"Z";
305
+ else if (val < 24) {
306
+ return math.roundToStr(val / 1.0e21, nDecimal) + "Z";
297
307
  }
298
- else
299
- {
300
- return math.roundToStr(val / 1.0e24, nDecimal)+"Y";
308
+ else {
309
+ return math.roundToStr(val / 1.0e24, nDecimal) + "Y";
301
310
  }
302
311
  }
303
312
 
304
- static wellFormatBin(val, nDecimal)
305
- {
313
+ /**
314
+ * @param {number} val
315
+ * @param {number | null} nDecimal
316
+ */
317
+ static wellFormatBin(val, nDecimal) {
306
318
  if (nDecimal == null || nDecimal < 1)
307
319
  nDecimal = 2;
308
- if (val < 1024)
309
- {
320
+ if (val < 1024) {
310
321
  return math.roundToStr(val, nDecimal);
311
322
  }
312
- else if (val < 1048576)
313
- {
314
- return math.roundToStr(val / 1024, nDecimal)+"Ki";
323
+ else if (val < 1048576) {
324
+ return math.roundToStr(val / 1024, nDecimal) + "Ki";
315
325
  }
316
- else if (val < 1073741824)
317
- {
318
- return math.roundToStr(val / 1048576, nDecimal)+"Mi";
326
+ else if (val < 1073741824) {
327
+ return math.roundToStr(val / 1048576, nDecimal) + "Mi";
319
328
  }
320
- else if (val < 1099511627776)
321
- {
322
- return math.roundToStr(val / 1073741824, nDecimal)+"Gi";
329
+ else if (val < 1099511627776) {
330
+ return math.roundToStr(val / 1073741824, nDecimal) + "Gi";
323
331
  }
324
- else
325
- {
326
- return math.roundToStr(val / 1099511627776, nDecimal)+"Ti";
332
+ else {
333
+ return math.roundToStr(val / 1099511627776, nDecimal) + "Ti";
327
334
  }
328
335
  }
329
336
  }
330
337
 
331
- export class Distance
332
- {
338
+ export class Distance {
333
339
  static Unit = {
334
340
  METER: 0,
335
341
  CENTIMETER: 1,
@@ -355,202 +361,217 @@ export class Distance
355
361
  PIXEL: 21,
356
362
  TWIP: 22
357
363
  }
358
-
359
- static getUnitInfo(u)
360
- {
361
- switch (u)
362
- {
363
- case Distance.Unit.METER:
364
- return new UnitInfo(u, "m", "Meter", 1.0);
365
- case Distance.Unit.CENTIMETER:
366
- return new UnitInfo(u, "cm", "Centimeter", 0.01);
367
- case Distance.Unit.MILLIMETER:
368
- return new UnitInfo(u, "mm", "Millimeter", 0.001);
369
- case Distance.Unit.MICROMETER:
370
- return new UnitInfo(u, "μm", "Micrometer", 0.000001);
371
- case Distance.Unit.NANOMETER:
372
- return new UnitInfo(u, "nm", "Nanometer", 0.000000001);
373
- case Distance.Unit.PICOMETER:
374
- return new UnitInfo(u, "pm", "Picometer", 0.000000000001);
375
- case Distance.Unit.KILOMETER:
376
- return new UnitInfo(u, "km", "Kilometer", 1000.0);
377
- case Distance.Unit.INCH:
378
- return new UnitInfo(u, "\"", "Inch", 0.0254);
379
- case Distance.Unit.FOOT:
380
- return new UnitInfo(u, "ft", "Foot", 0.0254 * 12.0);
381
- case Distance.Unit.YARD:
382
- return new UnitInfo(u, "yd", "Yard", 0.0254 * 36.0);
383
- case Distance.Unit.MILE:
384
- return new UnitInfo(u, "mile", "Mile", 0.0254 * 12.0 * 5280);
385
- case Distance.Unit.NAUTICAL_MILE:
386
- return new UnitInfo(u, "NM", "Nautical Mile", 1852.0);
387
- case Distance.Unit.AU:
388
- return new UnitInfo(u, "AU", "Astronomical unit", 149597870700.0);
389
- case Distance.Unit.LIGHTSECOND:
390
- return new UnitInfo(u, "ls", "Light-second", 299792458.0);
391
- case Distance.Unit.LIGHTMINUTE:
392
- return new UnitInfo(u, "lm", "Light-minute", 17987547480.0);
393
- case Distance.Unit.LIGHTHOUR:
394
- return new UnitInfo(u, "lh", "Light-hour", 299792458.0 * 3600.0);
395
- case Distance.Unit.LIGHTDAY:
396
- return new UnitInfo(u, "ld", "Light-day", 299792458.0 * 86400.0);
397
- case Distance.Unit.LIGHTWEEK:
398
- return new UnitInfo(u, "lw", "Light-week", 299792458.0 * 604800.0);
399
- case Distance.Unit.LIGHTYEAR:
400
- return new UnitInfo(u, "ly", "Light-year", 299792458.0 * 31557600.0);
401
- case Distance.Unit.EMU:
402
- return new UnitInfo(u, "emu", "English Metric Unit", 1 / 36000000.0);
403
- case Distance.Unit.POINT:
404
- return new UnitInfo(u, "pt", "Point", 0.0254 / 72.0);
405
- case Distance.Unit.PIXEL:
406
- return new UnitInfo(u, "px", "Pixel", 0.0254 / 96.0);
407
- case Distance.Unit.TWIP:
408
- return new UnitInfo(u, "twip", "Twentieth of an inch point", 0.0254 / 1440.0);
364
+
365
+ /**
366
+ * @param {number} u
367
+ */
368
+ static getUnitInfo(u) {
369
+ switch (u) {
370
+ case Distance.Unit.METER:
371
+ return new UnitInfo(u, "m", "Meter", 1.0);
372
+ case Distance.Unit.CENTIMETER:
373
+ return new UnitInfo(u, "cm", "Centimeter", 0.01);
374
+ case Distance.Unit.MILLIMETER:
375
+ return new UnitInfo(u, "mm", "Millimeter", 0.001);
376
+ case Distance.Unit.MICROMETER:
377
+ return new UnitInfo(u, "μm", "Micrometer", 0.000001);
378
+ case Distance.Unit.NANOMETER:
379
+ return new UnitInfo(u, "nm", "Nanometer", 0.000000001);
380
+ case Distance.Unit.PICOMETER:
381
+ return new UnitInfo(u, "pm", "Picometer", 0.000000000001);
382
+ case Distance.Unit.KILOMETER:
383
+ return new UnitInfo(u, "km", "Kilometer", 1000.0);
384
+ case Distance.Unit.INCH:
385
+ return new UnitInfo(u, "\"", "Inch", 0.0254);
386
+ case Distance.Unit.FOOT:
387
+ return new UnitInfo(u, "ft", "Foot", 0.0254 * 12.0);
388
+ case Distance.Unit.YARD:
389
+ return new UnitInfo(u, "yd", "Yard", 0.0254 * 36.0);
390
+ case Distance.Unit.MILE:
391
+ return new UnitInfo(u, "mile", "Mile", 0.0254 * 12.0 * 5280);
392
+ case Distance.Unit.NAUTICAL_MILE:
393
+ return new UnitInfo(u, "NM", "Nautical Mile", 1852.0);
394
+ case Distance.Unit.AU:
395
+ return new UnitInfo(u, "AU", "Astronomical unit", 149597870700.0);
396
+ case Distance.Unit.LIGHTSECOND:
397
+ return new UnitInfo(u, "ls", "Light-second", 299792458.0);
398
+ case Distance.Unit.LIGHTMINUTE:
399
+ return new UnitInfo(u, "lm", "Light-minute", 17987547480.0);
400
+ case Distance.Unit.LIGHTHOUR:
401
+ return new UnitInfo(u, "lh", "Light-hour", 299792458.0 * 3600.0);
402
+ case Distance.Unit.LIGHTDAY:
403
+ return new UnitInfo(u, "ld", "Light-day", 299792458.0 * 86400.0);
404
+ case Distance.Unit.LIGHTWEEK:
405
+ return new UnitInfo(u, "lw", "Light-week", 299792458.0 * 604800.0);
406
+ case Distance.Unit.LIGHTYEAR:
407
+ return new UnitInfo(u, "ly", "Light-year", 299792458.0 * 31557600.0);
408
+ case Distance.Unit.EMU:
409
+ return new UnitInfo(u, "emu", "English Metric Unit", 1 / 36000000.0);
410
+ case Distance.Unit.POINT:
411
+ return new UnitInfo(u, "pt", "Point", 0.0254 / 72.0);
412
+ case Distance.Unit.PIXEL:
413
+ return new UnitInfo(u, "px", "Pixel", 0.0254 / 96.0);
414
+ case Distance.Unit.TWIP:
415
+ return new UnitInfo(u, "twip", "Twentieth of an inch point", 0.0254 / 1440.0);
409
416
  }
410
417
  return null;
411
418
  }
412
419
 
413
- static getUnitRatio(u)
414
- {
415
- switch (u)
416
- {
417
- case Distance.Unit.METER:
418
- return 1.0;
419
- case Distance.Unit.CENTIMETER:
420
- return 0.01;
421
- case Distance.Unit.MILLIMETER:
422
- return 0.001;
423
- case Distance.Unit.MICROMETER:
424
- return 0.000001;
425
- case Distance.Unit.NANOMETER:
426
- return 0.000000001;
427
- case Distance.Unit.PICOMETER:
428
- return 0.000000000001;
429
- case Distance.Unit.KILOMETER:
430
- return 1000.0;
431
- case Distance.Unit.INCH:
432
- return 0.0254;
433
- case Distance.Unit.FOOT:
434
- return 0.0254 * 12.0;
435
- case Distance.Unit.YARD:
436
- return 0.0254 * 36.0;
437
- case Distance.Unit.MILE:
438
- return 0.0254 * 12.0 * 5280;
439
- case Distance.Unit.NAUTICAL_MILE:
440
- return 1852.0;
441
- case Distance.Unit.AU:
442
- return 149597870700.0;
443
- case Distance.Unit.LIGHTSECOND:
444
- return 299792458.0;
445
- case Distance.Unit.LIGHTMINUTE:
446
- return 17987547480.0;
447
- case Distance.Unit.LIGHTHOUR:
448
- return 299792458.0 * 3600.0;
449
- case Distance.Unit.LIGHTDAY:
450
- return 299792458.0 * 86400.0;
451
- case Distance.Unit.LIGHTWEEK:
452
- return 299792458.0 * 604800.0;
453
- case Distance.Unit.LIGHTYEAR:
454
- return 299792458.0 * 31557600.0;
455
- case Distance.Unit.EMU:
456
- return 1 / 36000000.0;
457
- case Distance.Unit.POINT:
458
- return 0.0254 / 72.0;
459
- case Distance.Unit.PIXEL:
460
- return 0.0254 / 96.0;
461
- case Distance.Unit.TWIP:
462
- return 0.0254 / 1440.0;
420
+ /**
421
+ * @param {number} u
422
+ */
423
+ static getUnitRatio(u) {
424
+ switch (u) {
425
+ case Distance.Unit.METER:
426
+ return 1.0;
427
+ case Distance.Unit.CENTIMETER:
428
+ return 0.01;
429
+ case Distance.Unit.MILLIMETER:
430
+ return 0.001;
431
+ case Distance.Unit.MICROMETER:
432
+ return 0.000001;
433
+ case Distance.Unit.NANOMETER:
434
+ return 0.000000001;
435
+ case Distance.Unit.PICOMETER:
436
+ return 0.000000000001;
437
+ case Distance.Unit.KILOMETER:
438
+ return 1000.0;
439
+ case Distance.Unit.INCH:
440
+ return 0.0254;
441
+ case Distance.Unit.FOOT:
442
+ return 0.0254 * 12.0;
443
+ case Distance.Unit.YARD:
444
+ return 0.0254 * 36.0;
445
+ case Distance.Unit.MILE:
446
+ return 0.0254 * 12.0 * 5280;
447
+ case Distance.Unit.NAUTICAL_MILE:
448
+ return 1852.0;
449
+ case Distance.Unit.AU:
450
+ return 149597870700.0;
451
+ case Distance.Unit.LIGHTSECOND:
452
+ return 299792458.0;
453
+ case Distance.Unit.LIGHTMINUTE:
454
+ return 17987547480.0;
455
+ case Distance.Unit.LIGHTHOUR:
456
+ return 299792458.0 * 3600.0;
457
+ case Distance.Unit.LIGHTDAY:
458
+ return 299792458.0 * 86400.0;
459
+ case Distance.Unit.LIGHTWEEK:
460
+ return 299792458.0 * 604800.0;
461
+ case Distance.Unit.LIGHTYEAR:
462
+ return 299792458.0 * 31557600.0;
463
+ case Distance.Unit.EMU:
464
+ return 1 / 36000000.0;
465
+ case Distance.Unit.POINT:
466
+ return 0.0254 / 72.0;
467
+ case Distance.Unit.PIXEL:
468
+ return 0.0254 / 96.0;
469
+ case Distance.Unit.TWIP:
470
+ return 0.0254 / 1440.0;
463
471
  }
464
472
  return 1;
465
473
  }
466
474
 
467
- static convert(fromUnit, toUnit, fromValue)
468
- {
475
+ /**
476
+ * @param {number} fromUnit
477
+ * @param {number} toUnit
478
+ * @param {number} fromValue
479
+ */
480
+ static convert(fromUnit, toUnit, fromValue) {
469
481
  return fromValue * Distance.getUnitRatio(fromUnit) / Distance.getUnitRatio(toUnit);
470
482
  }
471
483
  }
472
484
 
473
- export class ElectricCurrent
474
- {
485
+ export class ElectricCurrent {
475
486
  static Unit = {
476
487
  AMPERE: 1,
477
488
  MILLIAMPERE: 2,
478
489
  MICROAMPERE: 3
479
490
  };
480
491
 
481
- static getUnitInfo(u)
482
- {
483
- switch (u)
484
- {
485
- case ElectricCurrent.Unit.AMPERE:
486
- return new UnitInfo(u, "A", "Ampere", 1);
487
- case ElectricCurrent.Unit.MILLIAMPERE:
488
- return new UnitInfo(u, "mA", "Milliampere", 0.001);
489
- case ElectricCurrent.Unit.MICROAMPERE:
490
- return new UnitInfo(u, "μA", "Microampere", 0.000001);
492
+ /**
493
+ * @param {number} u
494
+ */
495
+ static getUnitInfo(u) {
496
+ switch (u) {
497
+ case ElectricCurrent.Unit.AMPERE:
498
+ return new UnitInfo(u, "A", "Ampere", 1);
499
+ case ElectricCurrent.Unit.MILLIAMPERE:
500
+ return new UnitInfo(u, "mA", "Milliampere", 0.001);
501
+ case ElectricCurrent.Unit.MICROAMPERE:
502
+ return new UnitInfo(u, "μA", "Microampere", 0.000001);
491
503
  }
492
504
  return null;
493
505
  }
494
506
 
495
- static getUnitRatio(u)
496
- {
497
- switch (u)
498
- {
499
- case ElectricCurrent.Unit.AMPERE:
500
- return 1;
501
- case ElectricCurrent.Unit.MILLIAMPERE:
502
- return 0.001;
503
- case ElectricCurrent.Unit.MICROAMPERE:
504
- return 0.000001;
507
+ /**
508
+ * @param {number} u
509
+ */
510
+ static getUnitRatio(u) {
511
+ switch (u) {
512
+ case ElectricCurrent.Unit.AMPERE:
513
+ return 1;
514
+ case ElectricCurrent.Unit.MILLIAMPERE:
515
+ return 0.001;
516
+ case ElectricCurrent.Unit.MICROAMPERE:
517
+ return 0.000001;
505
518
  }
506
519
  return 1;
507
520
  }
508
521
 
509
- static convert(fromUnit, toUnit, fromValue)
510
- {
522
+ /**
523
+ * @param {number} fromUnit
524
+ * @param {number} toUnit
525
+ * @param {number} fromValue
526
+ */
527
+ static convert(fromUnit, toUnit, fromValue) {
511
528
  return fromValue * ElectricCurrent.getUnitRatio(fromUnit) / ElectricCurrent.getUnitRatio(toUnit);
512
529
  }
513
530
  }
514
531
 
515
- export class ElectricPotential
516
- {
532
+ export class ElectricPotential {
517
533
  static Unit = {
518
534
  VOLT: 1,
519
535
  MILLIVOLT: 2
520
536
  };
521
537
 
522
- static getUnitInfo(u)
523
- {
524
- switch (u)
525
- {
526
- case ElectricPotential.Unit.VOLT:
527
- return new UnitInfo(u, "V", "Volt", 1);
528
- case ElectricPotential.Unit.MILLIVOLT:
529
- return new UnitInfo(u, "mV", "Millivolt", 0.001);
538
+ /**
539
+ * @param {number} u
540
+ */
541
+ static getUnitInfo(u) {
542
+ switch (u) {
543
+ case ElectricPotential.Unit.VOLT:
544
+ return new UnitInfo(u, "V", "Volt", 1);
545
+ case ElectricPotential.Unit.MILLIVOLT:
546
+ return new UnitInfo(u, "mV", "Millivolt", 0.001);
530
547
  }
531
548
  return null;
532
549
  }
533
550
 
534
- static getUnitRatio(u)
535
- {
536
- switch (u)
537
- {
538
- case ElectricPotential.Unit.VOLT:
539
- return 1;
540
- case ElectricPotential.Unit.MILLIVOLT:
541
- return 0.001;
551
+ /**
552
+ * @param {number} u
553
+ */
554
+ static getUnitRatio(u) {
555
+ switch (u) {
556
+ case ElectricPotential.Unit.VOLT:
557
+ return 1;
558
+ case ElectricPotential.Unit.MILLIVOLT:
559
+ return 0.001;
542
560
  }
543
561
  return 1;
544
562
  }
545
563
 
546
- static convert(fromUnit, toUnit, fromValue)
547
- {
564
+ /**
565
+ * @param {number} fromUnit
566
+ * @param {number} toUnit
567
+ * @param {number} fromValue
568
+ */
569
+ static convert(fromUnit, toUnit, fromValue) {
548
570
  return fromValue * ElectricPotential.getUnitRatio(fromUnit) / ElectricPotential.getUnitRatio(toUnit);
549
571
  }
550
572
  }
551
573
 
552
- export class Energy
553
- {
574
+ export class Energy {
554
575
  static Unit = {
555
576
  JOULE: 1,
556
577
  WATTHOUR: 2,
@@ -559,119 +580,134 @@ export class Energy
559
580
  KILOCALORIE: 5
560
581
  };
561
582
 
562
- static getUnitInfo(u)
563
- {
564
- switch (u)
565
- {
566
- case Energy.Unit.JOULE:
567
- return new UnitInfo(u, "J", "Joule", 1);
568
- case Energy.Unit.WATTHOUR:
569
- return new UnitInfo(u, "Wh", "Watt-hour", 3600.0);
570
- case Energy.Unit.KILOWATTHOUR:
571
- return new UnitInfo(u, "kWh", "Kilowatt-hour", 3600000.0);
572
- case Energy.Unit.CALORIE:
573
- return new UnitInfo(u, "cal", "Gram calorie", 4.184);
574
- case Energy.Unit.KILOCALORIE:
575
- return new UnitInfo(u, "kcal", "Kilocalorie", 4184);
583
+ /**
584
+ * @param {number} u
585
+ */
586
+ static getUnitInfo(u) {
587
+ switch (u) {
588
+ case Energy.Unit.JOULE:
589
+ return new UnitInfo(u, "J", "Joule", 1);
590
+ case Energy.Unit.WATTHOUR:
591
+ return new UnitInfo(u, "Wh", "Watt-hour", 3600.0);
592
+ case Energy.Unit.KILOWATTHOUR:
593
+ return new UnitInfo(u, "kWh", "Kilowatt-hour", 3600000.0);
594
+ case Energy.Unit.CALORIE:
595
+ return new UnitInfo(u, "cal", "Gram calorie", 4.184);
596
+ case Energy.Unit.KILOCALORIE:
597
+ return new UnitInfo(u, "kcal", "Kilocalorie", 4184);
576
598
  }
577
599
  return null;
578
600
  }
579
601
 
580
- static getUnitRatio(u)
581
- {
582
- switch (u)
583
- {
584
- case Energy.Unit.JOULE:
585
- return 1;
586
- case Energy.Unit.WATTHOUR:
587
- return 3600.0;
588
- case Energy.Unit.KILOWATTHOUR:
589
- return 3600000.0;
590
- case Energy.Unit.CALORIE:
591
- return 4.184;
592
- case Energy.Unit.KILOCALORIE:
593
- return 4184;
602
+ /**
603
+ * @param {number} u
604
+ */
605
+ static getUnitRatio(u) {
606
+ switch (u) {
607
+ case Energy.Unit.JOULE:
608
+ return 1;
609
+ case Energy.Unit.WATTHOUR:
610
+ return 3600.0;
611
+ case Energy.Unit.KILOWATTHOUR:
612
+ return 3600000.0;
613
+ case Energy.Unit.CALORIE:
614
+ return 4.184;
615
+ case Energy.Unit.KILOCALORIE:
616
+ return 4184;
594
617
  }
595
618
  return 1;
596
619
  }
597
620
 
598
- static convert(fromUnit, toUnit, fromValue)
599
- {
621
+ /**
622
+ * @param {number} fromUnit
623
+ * @param {number} toUnit
624
+ * @param {number} fromValue
625
+ */
626
+ static convert(fromUnit, toUnit, fromValue) {
600
627
  return fromValue * Energy.getUnitRatio(fromUnit) / Energy.getUnitRatio(toUnit);
601
628
  }
602
629
  }
603
630
 
604
- export class Force
605
- {
631
+ export class Force {
606
632
  static Unit = {
607
633
  NEWTON: 1
608
634
  };
609
635
 
610
- static getUnitInfo(u)
611
- {
612
- switch (u)
613
- {
614
- case Force.Unit.NEWTON:
615
- return new UnitInfo(u, "N", "Newton", 1);
636
+ /**
637
+ * @param {number} u
638
+ */
639
+ static getUnitInfo(u) {
640
+ switch (u) {
641
+ case Force.Unit.NEWTON:
642
+ return new UnitInfo(u, "N", "Newton", 1);
616
643
  }
617
644
  return null;
618
645
  }
619
646
 
620
- static getUnitRatio(u)
621
- {
622
- switch (u)
623
- {
624
- case Force.Unit.NEWTON:
625
- return 1;
647
+ /**
648
+ * @param {number} u
649
+ */
650
+ static getUnitRatio(u) {
651
+ switch (u) {
652
+ case Force.Unit.NEWTON:
653
+ return 1;
626
654
  }
627
655
  return 1;
628
656
  }
629
657
 
630
- static convert(fromUnit, toUnit, fromValue)
631
- {
658
+ /**
659
+ * @param {number} fromUnit
660
+ * @param {number} toUnit
661
+ * @param {number} fromValue
662
+ */
663
+ static convert(fromUnit, toUnit, fromValue) {
632
664
  return fromValue * Force.getUnitRatio(fromUnit) / Force.getUnitRatio(toUnit);
633
665
  }
634
666
  }
635
667
 
636
- export class Frequency
637
- {
668
+ export class Frequency {
638
669
  static Unit = {
639
670
  HERTZ: 1,
640
671
  KILOHERTZ: 2
641
672
  };
642
673
 
643
- static getUnitInfo(u)
644
- {
645
- switch (u)
646
- {
647
- case Frequency.Unit.HERTZ:
648
- return new UnitInfo(u, "Hz", "Hertz", 1);
649
- case Frequency.Unit.KILOHERTZ:
650
- return new UnitInfo(u, "kHz", "Kilohertz", 1000);
674
+ /**
675
+ * @param {number} u
676
+ */
677
+ static getUnitInfo(u) {
678
+ switch (u) {
679
+ case Frequency.Unit.HERTZ:
680
+ return new UnitInfo(u, "Hz", "Hertz", 1);
681
+ case Frequency.Unit.KILOHERTZ:
682
+ return new UnitInfo(u, "kHz", "Kilohertz", 1000);
651
683
  }
652
684
  return null;
653
685
  }
654
686
 
655
- static getUnitRatio(u)
656
- {
657
- switch (u)
658
- {
659
- case Frequency.Unit.HERTZ:
660
- return 1;
661
- case Frequency.Unit.KILOHERTZ:
662
- return 1000;
687
+ /**
688
+ * @param {number} u
689
+ */
690
+ static getUnitRatio(u) {
691
+ switch (u) {
692
+ case Frequency.Unit.HERTZ:
693
+ return 1;
694
+ case Frequency.Unit.KILOHERTZ:
695
+ return 1000;
663
696
  }
664
697
  return 1;
665
698
  }
666
699
 
667
- static convert(fromUnit, toUnit, fromValue)
668
- {
700
+ /**
701
+ * @param {number} fromUnit
702
+ * @param {number} toUnit
703
+ * @param {number} fromValue
704
+ */
705
+ static convert(fromUnit, toUnit, fromValue) {
669
706
  return fromValue * Frequency.getUnitRatio(fromUnit) / Frequency.getUnitRatio(toUnit);
670
707
  }
671
708
  }
672
709
 
673
- export class MagneticField
674
- {
710
+ export class MagneticField {
675
711
  static Unit = {
676
712
  TESLA: 1,
677
713
  GAUSS: 2,
@@ -679,46 +715,51 @@ export class MagneticField
679
715
  MILLITESLA: 4
680
716
  };
681
717
 
682
- static getUnitInfo(u)
683
- {
684
- switch (u)
685
- {
686
- case MagneticField.Unit.TESLA:
687
- return new UnitInfo(u, "T", "Tesla", 1);
688
- case MagneticField.Unit.GAUSS:
689
- return new UnitInfo(u, "G", "Gauss", 0.0001);
690
- case MagneticField.Unit.MICROTESLA:
691
- return new UnitInfo(u, "uT", "Micro Tesla", 0.000001);
692
- case MagneticField.Unit.MILLITESLA:
693
- return new UnitInfo(u, "mT", "Milli Tesla", 0.001);
718
+ /**
719
+ * @param {number} u
720
+ */
721
+ static getUnitInfo(u) {
722
+ switch (u) {
723
+ case MagneticField.Unit.TESLA:
724
+ return new UnitInfo(u, "T", "Tesla", 1);
725
+ case MagneticField.Unit.GAUSS:
726
+ return new UnitInfo(u, "G", "Gauss", 0.0001);
727
+ case MagneticField.Unit.MICROTESLA:
728
+ return new UnitInfo(u, "uT", "Micro Tesla", 0.000001);
729
+ case MagneticField.Unit.MILLITESLA:
730
+ return new UnitInfo(u, "mT", "Milli Tesla", 0.001);
694
731
  }
695
732
  return null;
696
733
  }
697
734
 
698
- static getUnitRatio(u)
699
- {
700
- switch (u)
701
- {
702
- case MagneticField.Unit.TESLA:
703
- return 1;
704
- case MagneticField.Unit.GAUSS:
705
- return 0.0001;
706
- case MagneticField.Unit.MICROTESLA:
707
- return 0.000001;
708
- case MagneticField.Unit.MILLITESLA:
709
- return 0.001;
735
+ /**
736
+ * @param {number} u
737
+ */
738
+ static getUnitRatio(u) {
739
+ switch (u) {
740
+ case MagneticField.Unit.TESLA:
741
+ return 1;
742
+ case MagneticField.Unit.GAUSS:
743
+ return 0.0001;
744
+ case MagneticField.Unit.MICROTESLA:
745
+ return 0.000001;
746
+ case MagneticField.Unit.MILLITESLA:
747
+ return 0.001;
710
748
  }
711
749
  return 1;
712
750
  }
713
751
 
714
- static convert(fromUnit, toUnit, fromValue)
715
- {
752
+ /**
753
+ * @param {number} fromUnit
754
+ * @param {number} toUnit
755
+ * @param {number} fromValue
756
+ */
757
+ static convert(fromUnit, toUnit, fromValue) {
716
758
  return fromValue * MagneticField.getUnitRatio(fromUnit) / MagneticField.getUnitRatio(toUnit);
717
759
  }
718
760
  }
719
761
 
720
- export class Mass
721
- {
762
+ export class Mass {
722
763
  static Unit = {
723
764
  KILOGRAM: 1,
724
765
  GRAM: 2,
@@ -727,92 +768,102 @@ export class Mass
727
768
  OZ: 5
728
769
  };
729
770
 
730
- static getUnitInfo(u)
731
- {
732
- switch (u)
733
- {
734
- case Mass.Unit.KILOGRAM:
735
- return new UnitInfo(u, "kg", "Kilogram", 1.0);
736
- case Mass.Unit.GRAM:
737
- return new UnitInfo(u, "g", "Gram", 0.001);
738
- case Mass.Unit.TONNE:
739
- return new UnitInfo(u, "t", "Tonne", 1000.0);
740
- case Mass.Unit.POUND:
741
- return new UnitInfo(u, "lb", "Pounds", 0.45359237);
742
- case Mass.Unit.OZ:
743
- return new UnitInfo(u, "oz", "Ounce", 0.45359237 / 16);
771
+ /**
772
+ * @param {number} u
773
+ */
774
+ static getUnitInfo(u) {
775
+ switch (u) {
776
+ case Mass.Unit.KILOGRAM:
777
+ return new UnitInfo(u, "kg", "Kilogram", 1.0);
778
+ case Mass.Unit.GRAM:
779
+ return new UnitInfo(u, "g", "Gram", 0.001);
780
+ case Mass.Unit.TONNE:
781
+ return new UnitInfo(u, "t", "Tonne", 1000.0);
782
+ case Mass.Unit.POUND:
783
+ return new UnitInfo(u, "lb", "Pounds", 0.45359237);
784
+ case Mass.Unit.OZ:
785
+ return new UnitInfo(u, "oz", "Ounce", 0.45359237 / 16);
744
786
  }
745
787
  return null;
746
788
  }
747
789
 
748
- static getUnitRatio(u)
749
- {
750
- switch (u)
751
- {
752
- case Mass.Unit.KILOGRAM:
753
- return 1.0;
754
- case Mass.Unit.GRAM:
755
- return 0.001;
756
- case Mass.Unit.TONNE:
757
- return 1000.0;
758
- case Mass.Unit.POUND:
759
- return 0.45359237;
760
- case Mass.Unit.OZ:
761
- return 0.45359237 / 16;
790
+ /**
791
+ * @param {number} u
792
+ */
793
+ static getUnitRatio(u) {
794
+ switch (u) {
795
+ case Mass.Unit.KILOGRAM:
796
+ return 1.0;
797
+ case Mass.Unit.GRAM:
798
+ return 0.001;
799
+ case Mass.Unit.TONNE:
800
+ return 1000.0;
801
+ case Mass.Unit.POUND:
802
+ return 0.45359237;
803
+ case Mass.Unit.OZ:
804
+ return 0.45359237 / 16;
762
805
  }
763
806
  return 1;
764
807
  }
765
808
 
766
- static convert(fromUnit, toUnit, fromValue)
767
- {
809
+ /**
810
+ * @param {number} fromUnit
811
+ * @param {number} toUnit
812
+ * @param {number} fromValue
813
+ */
814
+ static convert(fromUnit, toUnit, fromValue) {
768
815
  return fromValue * Mass.getUnitRatio(fromUnit) / Mass.getUnitRatio(toUnit);
769
816
  }
770
817
  }
771
818
 
772
- export class Power
773
- {
819
+ export class Power {
774
820
  static Unit = {
775
821
  WATT: 1,
776
822
  MILLIWATT: 2,
777
823
  KILOWATT: 3
778
824
  };
779
825
 
780
- static getUnitInfo(u)
781
- {
782
- switch (u)
783
- {
784
- case Power.Unit.WATT:
785
- return new UnitInfo(u, "W", "Watt", 1.0);
786
- case Power.Unit.MILLIWATT:
787
- return new UnitInfo(u, "mW", "Milliwatt", 0.001);
788
- case Power.Unit.KILOWATT:
789
- return new UnitInfo(u, "kW", "Kilowatt", 1000.0);
826
+ /**
827
+ * @param {number} u
828
+ */
829
+ static getUnitInfo(u) {
830
+ switch (u) {
831
+ case Power.Unit.WATT:
832
+ return new UnitInfo(u, "W", "Watt", 1.0);
833
+ case Power.Unit.MILLIWATT:
834
+ return new UnitInfo(u, "mW", "Milliwatt", 0.001);
835
+ case Power.Unit.KILOWATT:
836
+ return new UnitInfo(u, "kW", "Kilowatt", 1000.0);
790
837
  }
791
838
  return null;
792
839
  }
793
840
 
794
- static getUnitRatio(u)
795
- {
796
- switch (u)
797
- {
798
- case Power.Unit.WATT:
799
- return 1.0;
800
- case Power.Unit.MILLIWATT:
801
- return 0.001;
802
- case Power.Unit.KILOWATT:
803
- return 1000.0;
841
+ /**
842
+ * @param {number} u
843
+ */
844
+ static getUnitRatio(u) {
845
+ switch (u) {
846
+ case Power.Unit.WATT:
847
+ return 1.0;
848
+ case Power.Unit.MILLIWATT:
849
+ return 0.001;
850
+ case Power.Unit.KILOWATT:
851
+ return 1000.0;
804
852
  }
805
853
  return 1;
806
854
  }
807
855
 
808
- static convert(fromUnit, toUnit, fromValue)
809
- {
856
+ /**
857
+ * @param {number} fromUnit
858
+ * @param {number} toUnit
859
+ * @param {number} fromValue
860
+ */
861
+ static convert(fromUnit, toUnit, fromValue) {
810
862
  return fromValue * Power.getUnitRatio(fromUnit) / Power.getUnitRatio(toUnit);
811
863
  }
812
864
  }
813
865
 
814
- export class Pressure
815
- {
866
+ export class Pressure {
816
867
  static Unit = {
817
868
  PASCAL: 1,
818
869
  BAR: 2,
@@ -823,159 +874,179 @@ export class Pressure
823
874
  HPASCAL: 7
824
875
  };
825
876
 
826
- static getUnitInfo(u)
827
- {
828
- switch (u)
829
- {
830
- case Pressure.Unit.PASCAL:
831
- return new UnitInfo(u, "Pa", "Pascal", 1.0);
832
- case Pressure.Unit.BAR:
833
- return new UnitInfo(u, "bar", "Bar", 100000.0);
834
- case Pressure.Unit.ATM:
835
- return new UnitInfo(u, "atm", "Standard atmosphere", 101325.0);
836
- case Pressure.Unit.TORR:
837
- return new UnitInfo(u, "Torr", "Torr", 101325.0 / 760.0);
838
- case Pressure.Unit.PSI:
839
- return new UnitInfo(u, "psi", "Pounds per square inch", 4.4482216152605 / 0.0254 / 0.0254);
840
- case Pressure.Unit.KPASCAL:
841
- return new UnitInfo(u, "kPa", "Kilo Pascal", 1000.0);
842
- case Pressure.Unit.HPASCAL:
843
- return new UnitInfo(u, "hPa", "Hecto Pascal", 100.0);
877
+ /**
878
+ * @param {number} u
879
+ */
880
+ static getUnitInfo(u) {
881
+ switch (u) {
882
+ case Pressure.Unit.PASCAL:
883
+ return new UnitInfo(u, "Pa", "Pascal", 1.0);
884
+ case Pressure.Unit.BAR:
885
+ return new UnitInfo(u, "bar", "Bar", 100000.0);
886
+ case Pressure.Unit.ATM:
887
+ return new UnitInfo(u, "atm", "Standard atmosphere", 101325.0);
888
+ case Pressure.Unit.TORR:
889
+ return new UnitInfo(u, "Torr", "Torr", 101325.0 / 760.0);
890
+ case Pressure.Unit.PSI:
891
+ return new UnitInfo(u, "psi", "Pounds per square inch", 4.4482216152605 / 0.0254 / 0.0254);
892
+ case Pressure.Unit.KPASCAL:
893
+ return new UnitInfo(u, "kPa", "Kilo Pascal", 1000.0);
894
+ case Pressure.Unit.HPASCAL:
895
+ return new UnitInfo(u, "hPa", "Hecto Pascal", 100.0);
844
896
  }
845
897
  return null;
846
898
  }
847
899
 
848
- static getUnitRatio(u)
849
- {
850
- switch (u)
851
- {
852
- case Pressure.Unit.PASCAL:
853
- return 1.0;
854
- case Pressure.Unit.BAR:
855
- return 100000.0;
856
- case Pressure.Unit.ATM:
857
- return 101325.0;
858
- case Pressure.Unit.TORR:
859
- return 101325.0 / 760.0;
860
- case Pressure.Unit.PSI:
861
- return 4.4482216152605 / 0.0254 / 0.0254;
862
- case Pressure.Unit.KPASCAL:
863
- return 1000.0;
864
- case Pressure.Unit.HPASCAL:
865
- return 100.0;
900
+ /**
901
+ * @param {number} u
902
+ */
903
+ static getUnitRatio(u) {
904
+ switch (u) {
905
+ case Pressure.Unit.PASCAL:
906
+ return 1.0;
907
+ case Pressure.Unit.BAR:
908
+ return 100000.0;
909
+ case Pressure.Unit.ATM:
910
+ return 101325.0;
911
+ case Pressure.Unit.TORR:
912
+ return 101325.0 / 760.0;
913
+ case Pressure.Unit.PSI:
914
+ return 4.4482216152605 / 0.0254 / 0.0254;
915
+ case Pressure.Unit.KPASCAL:
916
+ return 1000.0;
917
+ case Pressure.Unit.HPASCAL:
918
+ return 100.0;
866
919
  }
867
920
  return 1;
868
921
  }
869
922
 
870
- static convert(fromUnit, toUnit, fromValue)
871
- {
923
+ /**
924
+ * @param {number} fromUnit
925
+ * @param {number} toUnit
926
+ * @param {number} fromValue
927
+ */
928
+ static convert(fromUnit, toUnit, fromValue) {
872
929
  return fromValue * Pressure.getUnitRatio(fromUnit) / Pressure.getUnitRatio(toUnit);
873
930
  }
874
931
  }
875
932
 
876
- export class Ratio
877
- {
933
+ export class Ratio {
878
934
  static Unit = {
879
935
  RATIO: 1,
880
936
  PERCENT: 2
881
937
  };
882
938
 
883
- static getUnitInfo(u)
884
- {
885
- switch (u)
886
- {
887
- case Ratio.Unit.RATIO:
888
- return new UnitInfo(u, "", "Ratio", 1.0);
889
- case Ratio.Unit.PERCENT:
890
- return new UnitInfo(u, "%", "Percent", 0.01);
939
+ /**
940
+ * @param {number} u
941
+ */
942
+ static getUnitInfo(u) {
943
+ switch (u) {
944
+ case Ratio.Unit.RATIO:
945
+ return new UnitInfo(u, "", "Ratio", 1.0);
946
+ case Ratio.Unit.PERCENT:
947
+ return new UnitInfo(u, "%", "Percent", 0.01);
891
948
  }
892
949
  return null;
893
950
  }
894
951
 
895
- static getUnitRatio(u)
896
- {
897
- switch (u)
898
- {
899
- case Ratio.Unit.RATIO:
900
- return 1.0;
901
- case Ratio.Unit.PERCENT:
902
- return 0.01;
952
+ /**
953
+ * @param {number} u
954
+ */
955
+ static getUnitRatio(u) {
956
+ switch (u) {
957
+ case Ratio.Unit.RATIO:
958
+ return 1.0;
959
+ case Ratio.Unit.PERCENT:
960
+ return 0.01;
903
961
  }
904
962
  return 1;
905
963
  }
906
964
 
907
- static convert(fromUnit, toUnit, fromValue)
908
- {
965
+ /**
966
+ * @param {number} fromUnit
967
+ * @param {number} toUnit
968
+ * @param {number} fromValue
969
+ */
970
+ static convert(fromUnit, toUnit, fromValue) {
909
971
  return fromValue * Ratio.getUnitRatio(fromUnit) / Ratio.getUnitRatio(toUnit);
910
972
  }
911
973
  }
912
974
 
913
- export class ReactiveEnergy
914
- {
975
+ export class ReactiveEnergy {
915
976
  static Unit = {
916
977
  KVARH: 1
917
978
  };
918
979
 
919
- static getUnitInfo(u)
920
- {
921
- switch (u)
922
- {
923
- case ReactiveEnergy.Unit.KVARH:
924
- return new UnitInfo(u, "kvarh", "Kilovolt-amperer hour", 1.0);
980
+ /**
981
+ * @param {number} u
982
+ */
983
+ static getUnitInfo(u) {
984
+ switch (u) {
985
+ case ReactiveEnergy.Unit.KVARH:
986
+ return new UnitInfo(u, "kvarh", "Kilovolt-amperer hour", 1.0);
925
987
  }
926
988
  return null;
927
989
  }
928
990
 
929
- static getUnitRatio(u)
930
- {
931
- switch (u)
932
- {
933
- case ReactiveEnergy.Unit.KVARH:
934
- return 1.0;
991
+ /**
992
+ * @param {number} u
993
+ */
994
+ static getUnitRatio(u) {
995
+ switch (u) {
996
+ case ReactiveEnergy.Unit.KVARH:
997
+ return 1.0;
935
998
  }
936
999
  return 1;
937
1000
  }
938
1001
 
939
- static convert(fromUnit, toUnit, fromValue)
940
- {
1002
+ /**
1003
+ * @param {number} fromUnit
1004
+ * @param {number} toUnit
1005
+ * @param {number} fromValue
1006
+ */
1007
+ static convert(fromUnit, toUnit, fromValue) {
941
1008
  return fromValue * ReactiveEnergy.getUnitRatio(fromUnit) / ReactiveEnergy.getUnitRatio(toUnit);
942
1009
  }
943
1010
  }
944
1011
 
945
- export class ReactivePower
946
- {
1012
+ export class ReactivePower {
947
1013
  static Unit = {
948
1014
  VAR: 1
949
1015
  };
950
1016
 
951
- static getUnitInfo(u)
952
- {
953
- switch (u)
954
- {
955
- case ReactivePower.Unit.VAR:
956
- return new UnitInfo(u, "", "Ratio", 1.0);
1017
+ /**
1018
+ * @param {number} u
1019
+ */
1020
+ static getUnitInfo(u) {
1021
+ switch (u) {
1022
+ case ReactivePower.Unit.VAR:
1023
+ return new UnitInfo(u, "", "Ratio", 1.0);
957
1024
  }
958
1025
  return null;
959
1026
  }
960
1027
 
961
- static getUnitRatio(u)
962
- {
963
- switch (u)
964
- {
965
- case ReactivePower.Unit.VAR:
966
- return 1.0;
1028
+ /**
1029
+ * @param {number} u
1030
+ */
1031
+ static getUnitRatio(u) {
1032
+ switch (u) {
1033
+ case ReactivePower.Unit.VAR:
1034
+ return 1.0;
967
1035
  }
968
1036
  return 1;
969
1037
  }
970
1038
 
971
- static convert(fromUnit, toUnit, fromValue)
972
- {
1039
+ /**
1040
+ * @param {number} fromUnit
1041
+ * @param {number} toUnit
1042
+ * @param {number} fromValue
1043
+ */
1044
+ static convert(fromUnit, toUnit, fromValue) {
973
1045
  return fromValue * ReactivePower.getUnitRatio(fromUnit) / ReactivePower.getUnitRatio(toUnit);
974
1046
  }
975
1047
  }
976
1048
 
977
- export class Speed
978
- {
1049
+ export class Speed {
979
1050
  static Unit = {
980
1051
  METER_PER_SECOND: 1,
981
1052
  KM_PER_HOUR: 2,
@@ -983,102 +1054,114 @@ export class Speed
983
1054
  KNOT: 4
984
1055
  };
985
1056
 
986
- static getUnitInfo(u)
987
- {
988
- switch (u)
989
- {
990
- case Speed.Unit.METER_PER_SECOND:
991
- return new UnitInfo(u, "m/s", "Meter per second", 1.0);
992
- case Speed.Unit.KM_PER_HOUR:
993
- return new UnitInfo(u, "km/h", "Kilometer per hour", 1000 / 3600.0);
994
- case Speed.Unit.MILE_PER_HOUR:
995
- return new UnitInfo(u, "mph", "Mile per hour", Distance.getUnitRatio(Distance.Unit.MILE) / 3600.0);
996
- case Speed.Unit.KNOT:
997
- return new UnitInfo(u, "knot", "Knot", Distance.getUnitRatio(Distance.Unit.NAUTICAL_MILE) / 3600.0);
1057
+ /**
1058
+ * @param {number} u
1059
+ */
1060
+ static getUnitInfo(u) {
1061
+ switch (u) {
1062
+ case Speed.Unit.METER_PER_SECOND:
1063
+ return new UnitInfo(u, "m/s", "Meter per second", 1.0);
1064
+ case Speed.Unit.KM_PER_HOUR:
1065
+ return new UnitInfo(u, "km/h", "Kilometer per hour", 1000 / 3600.0);
1066
+ case Speed.Unit.MILE_PER_HOUR:
1067
+ return new UnitInfo(u, "mph", "Mile per hour", Distance.getUnitRatio(Distance.Unit.MILE) / 3600.0);
1068
+ case Speed.Unit.KNOT:
1069
+ return new UnitInfo(u, "knot", "Knot", Distance.getUnitRatio(Distance.Unit.NAUTICAL_MILE) / 3600.0);
998
1070
  }
999
1071
  return null;
1000
1072
  }
1001
1073
 
1002
- static getUnitRatio(u)
1003
- {
1004
- switch (u)
1005
- {
1006
- case Speed.Unit.METER_PER_SECOND:
1007
- return 1.0;
1008
- case Speed.Unit.KM_PER_HOUR:
1009
- return 1000 / 3600.0;
1010
- case Speed.Unit.MILE_PER_HOUR:
1011
- return Distance.getUnitRatio(Distance.Unit.MILE) / 3600.0;
1012
- case Speed.Unit.KNOT:
1013
- return Distance.getUnitRatio(Distance.Unit.NAUTICAL_MILE) / 3600.0;
1074
+ /**
1075
+ * @param {number} u
1076
+ */
1077
+ static getUnitRatio(u) {
1078
+ switch (u) {
1079
+ case Speed.Unit.METER_PER_SECOND:
1080
+ return 1.0;
1081
+ case Speed.Unit.KM_PER_HOUR:
1082
+ return 1000 / 3600.0;
1083
+ case Speed.Unit.MILE_PER_HOUR:
1084
+ return Distance.getUnitRatio(Distance.Unit.MILE) / 3600.0;
1085
+ case Speed.Unit.KNOT:
1086
+ return Distance.getUnitRatio(Distance.Unit.NAUTICAL_MILE) / 3600.0;
1014
1087
  }
1015
1088
  return 1;
1016
1089
  }
1017
1090
 
1018
- static convert(fromUnit, toUnit, fromValue)
1019
- {
1091
+ /**
1092
+ * @param {number} fromUnit
1093
+ * @param {number} toUnit
1094
+ * @param {number} fromValue
1095
+ */
1096
+ static convert(fromUnit, toUnit, fromValue) {
1020
1097
  return fromValue * Speed.getUnitRatio(fromUnit) / Speed.getUnitRatio(toUnit);
1021
1098
  }
1022
1099
  }
1023
1100
 
1024
- export class Temperature
1025
- {
1101
+ export class Temperature {
1026
1102
  static Unit = {
1027
1103
  CELSIUS: 1,
1028
1104
  KELVIN: 2,
1029
1105
  FAHRENHEIT: 3
1030
1106
  };
1031
1107
 
1032
- static getUnitInfo(u)
1033
- {
1034
- switch (u)
1035
- {
1036
- case Temperature.Unit.CELSIUS:
1037
- return new UnitInfo(u, "℃", "Degree Celsius", 1.0, -273.15);
1038
- case Temperature.Unit.KELVIN:
1039
- return new UnitInfo(u, "K", "Kelvin", 1.0, 0.0);
1040
- case Temperature.Unit.FAHRENHEIT:
1041
- return new UnitInfo(u, "℉", "Degree Fahrenheit", 5/9, -459.67);
1108
+ /**
1109
+ * @param {number} u
1110
+ */
1111
+ static getUnitInfo(u) {
1112
+ switch (u) {
1113
+ case Temperature.Unit.CELSIUS:
1114
+ return new UnitInfo(u, "℃", "Degree Celsius", 1.0, -273.15);
1115
+ case Temperature.Unit.KELVIN:
1116
+ return new UnitInfo(u, "K", "Kelvin", 1.0, 0.0);
1117
+ case Temperature.Unit.FAHRENHEIT:
1118
+ return new UnitInfo(u, "℉", "Degree Fahrenheit", 5 / 9, -459.67);
1042
1119
  }
1043
1120
  return null;
1044
1121
  }
1045
1122
 
1046
- static getUnitRatio(u)
1047
- {
1048
- switch (u)
1049
- {
1050
- case Temperature.Unit.CELSIUS:
1051
- return 1.0;
1052
- case Temperature.Unit.KELVIN:
1053
- return 1.0;
1054
- case Temperature.Unit.FAHRENHEIT:
1055
- return 5/9;
1123
+ /**
1124
+ * @param {number} u
1125
+ */
1126
+ static getUnitRatio(u) {
1127
+ switch (u) {
1128
+ case Temperature.Unit.CELSIUS:
1129
+ return 1.0;
1130
+ case Temperature.Unit.KELVIN:
1131
+ return 1.0;
1132
+ case Temperature.Unit.FAHRENHEIT:
1133
+ return 5 / 9;
1056
1134
  }
1057
1135
  return 1;
1058
1136
  }
1059
1137
 
1060
- static getUnitScale(u)
1061
- {
1062
- switch (u)
1063
- {
1064
- case Temperature.Unit.CELSIUS:
1065
- return -273.15;
1066
- case Temperature.Unit.KELVIN:
1067
- return 0.0;
1068
- case Temperature.Unit.FAHRENHEIT:
1069
- return -459.67;
1138
+ /**
1139
+ * @param {number} u
1140
+ */
1141
+ static getUnitScale(u) {
1142
+ switch (u) {
1143
+ case Temperature.Unit.CELSIUS:
1144
+ return -273.15;
1145
+ case Temperature.Unit.KELVIN:
1146
+ return 0.0;
1147
+ case Temperature.Unit.FAHRENHEIT:
1148
+ return -459.67;
1070
1149
  }
1071
1150
  return null;
1072
1151
  }
1073
1152
 
1074
- static convert(fromUnit, toUnit, fromValue)
1075
- {
1153
+ /**
1154
+ * @param {number} fromUnit
1155
+ * @param {number} toUnit
1156
+ * @param {number} fromValue
1157
+ */
1158
+ static convert(fromUnit, toUnit, fromValue) {
1159
+ // @ts-ignore
1076
1160
  return (fromValue * Temperature.getUnitRatio(fromUnit) - Temperature.getUnitScale(fromUnit)) / Temperature.getUnitRatio(toUnit) + Temperature.getUnitScale(toUnit);
1077
1161
  }
1078
1162
  }
1079
1163
 
1080
- export function getList()
1081
- {
1164
+ export function getList() {
1082
1165
  return [
1083
1166
  Acceleration,
1084
1167
  Angle,