uom-types 3.1.0 → 4.0.0
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/CHANGELOG.md +119 -0
- package/README.md +26 -27
- package/dist/{units-converters.cjs → index.cjs} +366 -81
- package/dist/index.d.cts +4522 -9
- package/dist/index.d.mts +4522 -9
- package/dist/{units-converters.mjs → index.mjs} +263 -14
- package/package.json +108 -110
- package/dist/_angle-plane.d.cts +0 -89
- package/dist/_angle-plane.d.mts +0 -89
- package/dist/_identity.d.cts +0 -29
- package/dist/_identity.d.mts +0 -29
- package/dist/_time-duration.d.cts +0 -482
- package/dist/_time-duration.d.mts +0 -482
- package/dist/_units.d.cts +0 -258
- package/dist/_units.d.mts +0 -258
- package/dist/functions-higher-order.cjs +0 -125
- package/dist/functions-higher-order.d.cts +0 -91
- package/dist/functions-higher-order.d.mts +0 -91
- package/dist/functions-higher-order.mjs +0 -111
- package/dist/functions.cjs +0 -333
- package/dist/functions.d.cts +0 -243
- package/dist/functions.d.mts +0 -243
- package/dist/functions.mjs +0 -296
- package/dist/units-converters.d.cts +0 -370
- package/dist/units-converters.d.mts +0 -370
- package/dist/units.d.cts +0 -3056
- package/dist/units.d.mts +0 -3056
|
@@ -1,170 +1,419 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function add(...args) {
|
|
4
|
+
return args.length === 1 ? (a) => a + args[0] : args[0] + args[1];
|
|
5
|
+
}
|
|
6
|
+
function sub(...args) {
|
|
7
|
+
return args.length === 1 ? (a) => a - args[0] : args[0] - args[1];
|
|
8
|
+
}
|
|
9
|
+
function mul(...args) {
|
|
10
|
+
return args.length === 1 ? (a) => a * args[0] : args[0] * args[1];
|
|
11
|
+
}
|
|
12
|
+
function div(...args) {
|
|
13
|
+
return args.length === 1 ? (a) => a / args[0] : args[0] / args[1];
|
|
14
|
+
}
|
|
15
|
+
function mod(...args) {
|
|
16
|
+
return args.length === 1 ? (a) => a % args[0] : args[0] % args[1];
|
|
17
|
+
}
|
|
18
|
+
function modSafe(...args) {
|
|
19
|
+
return args.length === 1
|
|
20
|
+
? (a) => ((a % args[0]) + args[0]) % args[0]
|
|
21
|
+
: ((args[0] % args[1]) + args[1]) % args[1];
|
|
22
|
+
}
|
|
23
|
+
function pow(...args) {
|
|
24
|
+
return args.length === 1 ? (b) => b ** args[0] : args[0] ** args[1];
|
|
25
|
+
}
|
|
26
|
+
function root(...args) {
|
|
27
|
+
return args.length === 1 ? (b) => b ** (1 / args[0]) : args[0] ** (1 / args[1]);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Take the square root of the given value.
|
|
31
|
+
*
|
|
32
|
+
* @category Math
|
|
33
|
+
* @returns `value ** (1/2)`
|
|
34
|
+
*/
|
|
35
|
+
function sqrt(value) {
|
|
36
|
+
return root(value, 2);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Inverse the given value.
|
|
40
|
+
*
|
|
41
|
+
* @category Math
|
|
42
|
+
* @returns `value ** -1`
|
|
43
|
+
*/
|
|
44
|
+
function inverse(value) {
|
|
45
|
+
return pow(value, -1);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the negative of the given value.
|
|
49
|
+
*
|
|
50
|
+
* @category Math
|
|
51
|
+
* @returns `-value`
|
|
52
|
+
*/
|
|
53
|
+
function negate(value) {
|
|
54
|
+
return -value;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns the absolute value of the given value.
|
|
58
|
+
*
|
|
59
|
+
* @category Math
|
|
60
|
+
* @returns `Math.abs(value)`
|
|
61
|
+
*/
|
|
62
|
+
function abs(value) {
|
|
63
|
+
return Math.abs(value);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the greatest integer less than or equal to the given value.
|
|
67
|
+
*
|
|
68
|
+
* @category Math
|
|
69
|
+
* @returns `Math.floor(value)`
|
|
70
|
+
*/
|
|
71
|
+
function floor(value) {
|
|
72
|
+
return Math.floor(value);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns the smallest integer greater than or equal the given value.
|
|
76
|
+
*
|
|
77
|
+
* @category Math
|
|
78
|
+
* @returns `Math.ceil(value)`
|
|
79
|
+
*/
|
|
80
|
+
function ceil(value) {
|
|
81
|
+
return Math.ceil(value);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns the given value rounded to the nearest integer.
|
|
85
|
+
*
|
|
86
|
+
* @category Math
|
|
87
|
+
* @returns `Math.round(value)`
|
|
88
|
+
*/
|
|
89
|
+
function round(value) {
|
|
90
|
+
return Math.round(value);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns the larger value in the given collection.
|
|
94
|
+
*
|
|
95
|
+
* @category Math
|
|
96
|
+
* @returns `Math.max(values)`
|
|
97
|
+
*/
|
|
98
|
+
function max(values) {
|
|
99
|
+
return Math.max(...values);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the smallest value in the given collection.
|
|
103
|
+
*
|
|
104
|
+
* @category Math
|
|
105
|
+
* @returns `Math.min(values)`
|
|
106
|
+
*/
|
|
107
|
+
function min(values) {
|
|
108
|
+
return Math.min(...values);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Takes the sum of all the values in the given collection.
|
|
112
|
+
*
|
|
113
|
+
* @category Math
|
|
114
|
+
* @returns `Math.sum(values)`
|
|
115
|
+
*/
|
|
116
|
+
function sum(values) {
|
|
117
|
+
return [...values].reduce(add, 0);
|
|
118
|
+
}
|
|
119
|
+
function eq(...args) {
|
|
120
|
+
return args.length === 1 ? (a) => a === args[0] : args[0] === args[1];
|
|
121
|
+
}
|
|
122
|
+
function gt(...args) {
|
|
123
|
+
return args.length === 1 ? (a) => a > args[0] : args[0] > args[1];
|
|
124
|
+
}
|
|
125
|
+
function gte(...args) {
|
|
126
|
+
return args.length === 1 ? (a) => a >= args[0] : args[0] >= args[1];
|
|
127
|
+
}
|
|
128
|
+
function lt(...args) {
|
|
129
|
+
return args.length === 1 ? (a) => a < args[0] : args[0] < args[1];
|
|
130
|
+
}
|
|
131
|
+
function lte(...args) {
|
|
132
|
+
return args.length === 1 ? (a) => a <= args[0] : args[0] <= args[1];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns the sine of a number.
|
|
136
|
+
*
|
|
137
|
+
* @category Math
|
|
138
|
+
* @returns `Math.sin(angle)`
|
|
139
|
+
*/
|
|
140
|
+
function sin(angle) {
|
|
141
|
+
return Math.sin(angle);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Returns the cosine of a number.
|
|
145
|
+
*
|
|
146
|
+
* @category Math
|
|
147
|
+
* @returns `Math.cos(angle)`
|
|
148
|
+
*/
|
|
149
|
+
function cos(angle) {
|
|
150
|
+
return Math.cos(angle);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Returns the tangent of a number.
|
|
154
|
+
*
|
|
155
|
+
* @category Math
|
|
156
|
+
* @returns `Math.tan(angle)`
|
|
157
|
+
*/
|
|
158
|
+
function tan(angle) {
|
|
159
|
+
return Math.tan(angle);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Returns the arcsine of a number.
|
|
163
|
+
*
|
|
164
|
+
* @category Math
|
|
165
|
+
* @returns `Math.asin(value)`
|
|
166
|
+
*/
|
|
167
|
+
function asin(value) {
|
|
168
|
+
return Math.asin(value);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Returns the arc cosine (or inverse cosine) of a number.
|
|
172
|
+
*
|
|
173
|
+
* @category Math
|
|
174
|
+
* @returns `Math.acos(value)`
|
|
175
|
+
*/
|
|
176
|
+
function acos(value) {
|
|
177
|
+
return Math.acos(value);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Returns the arctangent of a number.
|
|
181
|
+
*
|
|
182
|
+
* @category Math
|
|
183
|
+
* @returns `Math.atan(value)`
|
|
184
|
+
*/
|
|
185
|
+
function atan(value) {
|
|
186
|
+
return Math.atan(value);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Returns the angle (in radians) from the X axis to a point.
|
|
190
|
+
*
|
|
191
|
+
* @category Math
|
|
192
|
+
* @param x - A number representing the cartesian x-coordinate.
|
|
193
|
+
* @param y - A number representing the cartesian y-coordinate.
|
|
194
|
+
* @returns `Math.atan2(x, y)`
|
|
195
|
+
*/
|
|
196
|
+
function atan2(x, y) {
|
|
197
|
+
return Math.atan2(x, y);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Returns the hyperbolic sine of a number.
|
|
201
|
+
*
|
|
202
|
+
* @category Math
|
|
203
|
+
* @returns `Math.sinh(angle)`
|
|
204
|
+
*/
|
|
205
|
+
function sinh(angle) {
|
|
206
|
+
return Math.sinh(angle);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Returns the hyperbolic cosine of a number.
|
|
210
|
+
*
|
|
211
|
+
* @category Math
|
|
212
|
+
* @returns `Math.cosh(angle)`
|
|
213
|
+
*/
|
|
214
|
+
function cosh(angle) {
|
|
215
|
+
return Math.cosh(angle);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Returns the hyperbolic tangent of a number.
|
|
219
|
+
*
|
|
220
|
+
* @category Math
|
|
221
|
+
* @returns `Math.tanh(angle)`
|
|
222
|
+
*/
|
|
223
|
+
function tanh(angle) {
|
|
224
|
+
return Math.tanh(angle);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Returns the inverse hyperbolic sine of a number.
|
|
228
|
+
*
|
|
229
|
+
* @category Math
|
|
230
|
+
* @returns `Math.asinh(value)`
|
|
231
|
+
*/
|
|
232
|
+
function asinh(value) {
|
|
233
|
+
return Math.asinh(value);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns the inverse hyperbolic cosine of a number.
|
|
237
|
+
*
|
|
238
|
+
* @category Math
|
|
239
|
+
* @returns `Math.acosh(value)`
|
|
240
|
+
*/
|
|
241
|
+
function acosh(value) {
|
|
242
|
+
return Math.acosh(value);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Returns the inverse hyperbolic tangent of a number.
|
|
246
|
+
*
|
|
247
|
+
* @category Math
|
|
248
|
+
* @returns `Math.atanh(value)`
|
|
249
|
+
*/
|
|
250
|
+
function atanh(value) {
|
|
251
|
+
return Math.atanh(value);
|
|
252
|
+
}
|
|
4
253
|
|
|
5
254
|
/**
|
|
6
255
|
* Convert {@link Radian} to {@link Degree}.
|
|
7
256
|
*/
|
|
8
257
|
function radiansToDegrees(angle) {
|
|
9
|
-
return
|
|
258
|
+
return mul(angle, (180 / Math.PI));
|
|
10
259
|
}
|
|
11
260
|
/**
|
|
12
261
|
* Convert {@link Radian} to {@link Gradian}.
|
|
13
262
|
*/
|
|
14
263
|
function radiansToGradians(angle) {
|
|
15
|
-
return
|
|
264
|
+
return mul(angle, (200 / Math.PI));
|
|
16
265
|
}
|
|
17
266
|
/**
|
|
18
267
|
* Convert {@link Radian} to {@link Turn}.
|
|
19
268
|
*/
|
|
20
269
|
function radiansToTurns(angle) {
|
|
21
|
-
return
|
|
270
|
+
return div(angle, Math.PI);
|
|
22
271
|
}
|
|
23
272
|
/**
|
|
24
273
|
* Convert {@link Degree} to {@link Radian}.
|
|
25
274
|
*/
|
|
26
275
|
function degreesToRadians(angle) {
|
|
27
|
-
return
|
|
276
|
+
return mul(angle, (Math.PI / 180));
|
|
28
277
|
}
|
|
29
278
|
/**
|
|
30
279
|
* Convert {@link Degree} to {@link Gradian}.
|
|
31
280
|
*/
|
|
32
281
|
function degreesToGradians(angle) {
|
|
33
|
-
return
|
|
282
|
+
return mul(angle, (10 / 9));
|
|
34
283
|
}
|
|
35
284
|
/**
|
|
36
285
|
* Convert {@link Degree} to {@link Turn}.
|
|
37
286
|
*/
|
|
38
287
|
function degreesToTurns(angle) {
|
|
39
|
-
return
|
|
288
|
+
return div(angle, 360);
|
|
40
289
|
}
|
|
41
290
|
/**
|
|
42
291
|
* Convert {@link Gradian} to {@link Radian}.
|
|
43
292
|
*/
|
|
44
293
|
function gradiansToRadians(angle) {
|
|
45
|
-
return
|
|
294
|
+
return mul(angle, (Math.PI / 400));
|
|
46
295
|
}
|
|
47
296
|
/**
|
|
48
297
|
* Convert {@link Gradian} to {@link Degree}.
|
|
49
298
|
*/
|
|
50
299
|
function gradiansToDegrees(angle) {
|
|
51
|
-
return
|
|
300
|
+
return mul(angle, (9 / 10));
|
|
52
301
|
}
|
|
53
302
|
/**
|
|
54
303
|
* Convert {@link Gradian} to {@link Turn}.
|
|
55
304
|
*/
|
|
56
305
|
function gradiansToTurns(angle) {
|
|
57
|
-
return
|
|
306
|
+
return div(angle, 400);
|
|
58
307
|
}
|
|
59
308
|
/**
|
|
60
309
|
* Convert {@link Turn} to {@link Radian}.
|
|
61
310
|
*/
|
|
62
311
|
function turnsToRadians(angle) {
|
|
63
|
-
return
|
|
312
|
+
return mul(angle, (2 * Math.PI));
|
|
64
313
|
}
|
|
65
314
|
/**
|
|
66
315
|
* Convert {@link Turn} to {@link Degree}.
|
|
67
316
|
*/
|
|
68
317
|
function turnsToDegrees(angle) {
|
|
69
|
-
return
|
|
318
|
+
return mul(angle, 360);
|
|
70
319
|
}
|
|
71
320
|
/**
|
|
72
321
|
* Convert {@link Turn} to {@link Gradian}.
|
|
73
322
|
*/
|
|
74
323
|
function turnsToGradians(angle) {
|
|
75
|
-
return
|
|
324
|
+
return mul(angle, 400);
|
|
76
325
|
}
|
|
77
326
|
|
|
78
327
|
/**
|
|
79
|
-
* Convert {@link Square}<{@link
|
|
328
|
+
* Convert {@link Square}<{@link Meter}> to {@link Are}.
|
|
80
329
|
*/
|
|
81
|
-
function
|
|
82
|
-
return
|
|
330
|
+
function squareMetersToAres(area) {
|
|
331
|
+
return div(area, 100);
|
|
83
332
|
}
|
|
84
333
|
/**
|
|
85
|
-
* Convert {@link Square}<{@link
|
|
334
|
+
* Convert {@link Square}<{@link Meter}> to {@link Hectare}.
|
|
86
335
|
*/
|
|
87
|
-
function
|
|
88
|
-
return
|
|
336
|
+
function squareMetersToHectares(area) {
|
|
337
|
+
return div(area, 10_000);
|
|
89
338
|
}
|
|
90
339
|
/**
|
|
91
|
-
* Convert {@link Are} to {@link Square}<{@link
|
|
340
|
+
* Convert {@link Are} to {@link Square}<{@link Meter}>.
|
|
92
341
|
*/
|
|
93
|
-
function
|
|
94
|
-
return
|
|
342
|
+
function aresToSquareMeters(area) {
|
|
343
|
+
return mul(area, 100);
|
|
95
344
|
}
|
|
96
345
|
/**
|
|
97
346
|
* Convert {@link Are} to {@link Hectare}.
|
|
98
347
|
*/
|
|
99
348
|
function aresToHectares(area) {
|
|
100
|
-
return
|
|
349
|
+
return div(area, 100);
|
|
101
350
|
}
|
|
102
351
|
/**
|
|
103
|
-
* Convert {@link Hectare} to {@link Square}<{@link
|
|
352
|
+
* Convert {@link Hectare} to {@link Square}<{@link Meter}>.
|
|
104
353
|
*/
|
|
105
|
-
function
|
|
106
|
-
return
|
|
354
|
+
function hectaresToSquareMeters(area) {
|
|
355
|
+
return mul(area, 10_000);
|
|
107
356
|
}
|
|
108
357
|
/**
|
|
109
358
|
* Convert {@link Hectare} to {@link Are}.
|
|
110
359
|
*/
|
|
111
360
|
function hectaresToAres(area) {
|
|
112
|
-
return
|
|
361
|
+
return mul(area, 100);
|
|
113
362
|
}
|
|
114
363
|
|
|
115
364
|
/**
|
|
116
365
|
* Convert {@link Second} to {@link Minute}.
|
|
117
366
|
*/
|
|
118
367
|
function secondsToMinutes(duration) {
|
|
119
|
-
return
|
|
368
|
+
return div(duration, 60);
|
|
120
369
|
}
|
|
121
370
|
/**
|
|
122
371
|
* Convert {@link Second} to {@link Hour}.
|
|
123
372
|
*/
|
|
124
373
|
function secondsToHours(duration) {
|
|
125
|
-
return
|
|
374
|
+
return div(duration, 3600);
|
|
126
375
|
}
|
|
127
376
|
/**
|
|
128
377
|
* Convert {@link Minute} to {@link Second}.
|
|
129
378
|
*/
|
|
130
379
|
function minutesToSeconds(duration) {
|
|
131
|
-
return
|
|
380
|
+
return mul(duration, 60);
|
|
132
381
|
}
|
|
133
382
|
/**
|
|
134
383
|
* Convert {@link Minute} to {@link Hour}.
|
|
135
384
|
*/
|
|
136
385
|
function minutesToHours(duration) {
|
|
137
|
-
return
|
|
386
|
+
return div(duration, 60);
|
|
138
387
|
}
|
|
139
388
|
/**
|
|
140
389
|
* Convert {@link Hour} to {@link Second}.
|
|
141
390
|
*/
|
|
142
391
|
function hoursToSeconds(duration) {
|
|
143
|
-
return
|
|
392
|
+
return mul(duration, 3600);
|
|
144
393
|
}
|
|
145
394
|
/**
|
|
146
395
|
* Convert {@link Hour} to {@link Minute}.
|
|
147
396
|
*/
|
|
148
397
|
function hoursToMinutes(duration) {
|
|
149
|
-
return
|
|
398
|
+
return mul(duration, 60);
|
|
150
399
|
}
|
|
151
400
|
/**
|
|
152
401
|
* Convert {@link Hour} to {@link Day}.
|
|
153
402
|
*/
|
|
154
403
|
function hoursToDays(duration) {
|
|
155
|
-
return
|
|
404
|
+
return div(duration, 24);
|
|
156
405
|
}
|
|
157
406
|
/**
|
|
158
407
|
* Convert {@link Day} to {@link Hour}.
|
|
159
408
|
*/
|
|
160
409
|
function daysToHours(duration) {
|
|
161
|
-
return
|
|
410
|
+
return mul(duration, 24);
|
|
162
411
|
}
|
|
163
412
|
/**
|
|
164
413
|
* Convert {@link Day} to {@link Week}.
|
|
165
414
|
*/
|
|
166
415
|
function daysToWeeks(duration) {
|
|
167
|
-
return
|
|
416
|
+
return div(duration, 7);
|
|
168
417
|
}
|
|
169
418
|
/**
|
|
170
419
|
* Convert {@link Day} to {@link Year}.
|
|
@@ -173,13 +422,13 @@ function daysToWeeks(duration) {
|
|
|
173
422
|
* Use an actual date/time library if you need more control.
|
|
174
423
|
*/
|
|
175
424
|
function daysToYears(duration) {
|
|
176
|
-
return
|
|
425
|
+
return div(duration, 365.25);
|
|
177
426
|
}
|
|
178
427
|
/**
|
|
179
428
|
* Convert {@link Week} to {@link Day}.
|
|
180
429
|
*/
|
|
181
430
|
function weeksToDays(duration) {
|
|
182
|
-
return
|
|
431
|
+
return mul(duration, 7);
|
|
183
432
|
}
|
|
184
433
|
/**
|
|
185
434
|
* Convert {@link Week} to {@link Year}.
|
|
@@ -194,7 +443,7 @@ function weeksToYears(duration) {
|
|
|
194
443
|
* Use an actual date/time library if you need more control.
|
|
195
444
|
*/
|
|
196
445
|
function yearsToDays(duration) {
|
|
197
|
-
return
|
|
446
|
+
return mul(duration, 365.25);
|
|
198
447
|
}
|
|
199
448
|
/**
|
|
200
449
|
* Convert {@link Year} to {@link Week}.
|
|
@@ -207,80 +456,80 @@ function yearsToWeeks(duration) {
|
|
|
207
456
|
* Convert {@link Joule} to {@link WattMinute}.
|
|
208
457
|
*/
|
|
209
458
|
function joulesToWattMinutes(energy) {
|
|
210
|
-
return
|
|
459
|
+
return div(energy, 60);
|
|
211
460
|
}
|
|
212
461
|
/**
|
|
213
462
|
* Convert {@link Joule} to {@link WattHour}.
|
|
214
463
|
*/
|
|
215
464
|
function joulesToWattHours(energy) {
|
|
216
|
-
return
|
|
465
|
+
return div(energy, 3600);
|
|
217
466
|
}
|
|
218
467
|
/**
|
|
219
468
|
* Convert {@link WattMinute} to {@link Joule}.
|
|
220
469
|
*/
|
|
221
470
|
function wattMinutesToJoules(energy) {
|
|
222
|
-
return
|
|
471
|
+
return mul(energy, 60);
|
|
223
472
|
}
|
|
224
473
|
/**
|
|
225
474
|
* Convert {@link WattHour} to {@link Joule}.
|
|
226
475
|
*/
|
|
227
476
|
function wattHoursToJoules(energy) {
|
|
228
|
-
return
|
|
477
|
+
return mul(energy, 3600);
|
|
229
478
|
}
|
|
230
479
|
|
|
231
480
|
/**
|
|
232
481
|
* Convert {@link Hertz} to {@link PerMinute}.
|
|
233
482
|
*/
|
|
234
483
|
function hertzToPerMinute(frequency) {
|
|
235
|
-
return
|
|
484
|
+
return mul(frequency, 60);
|
|
236
485
|
}
|
|
237
486
|
/**
|
|
238
487
|
* Convert {@link Hertz} to {@link PerHour}.
|
|
239
488
|
*/
|
|
240
489
|
function hertzToPerHour(frequency) {
|
|
241
|
-
return
|
|
490
|
+
return mul(frequency, 3600);
|
|
242
491
|
}
|
|
243
492
|
/**
|
|
244
493
|
* Convert {@link PerMinute} to {@link Hertz}.
|
|
245
494
|
*/
|
|
246
495
|
function perMinuteToHertz(frequency) {
|
|
247
|
-
return
|
|
496
|
+
return div(frequency, 60);
|
|
248
497
|
}
|
|
249
498
|
/**
|
|
250
499
|
* Convert {@link PerMinute} to {@link PerHour}.
|
|
251
500
|
*/
|
|
252
501
|
function perMinuteToPerHour(frequency) {
|
|
253
|
-
return
|
|
502
|
+
return mul(frequency, 60);
|
|
254
503
|
}
|
|
255
504
|
/**
|
|
256
505
|
* Convert {@link PerHour} to {@link Hertz}.
|
|
257
506
|
*/
|
|
258
507
|
function perHourToHertz(frequency) {
|
|
259
|
-
return
|
|
508
|
+
return div(frequency, 3600);
|
|
260
509
|
}
|
|
261
510
|
/**
|
|
262
511
|
* Convert {@link PerHour} to {@link PerMinute}.
|
|
263
512
|
*/
|
|
264
513
|
function perHourToPerMinute(frequency) {
|
|
265
|
-
return
|
|
514
|
+
return div(frequency, 60);
|
|
266
515
|
}
|
|
267
516
|
/**
|
|
268
517
|
* Convert {@link PerHour} to {@link PerDay}.
|
|
269
518
|
*/
|
|
270
519
|
function perHourToPerDay(frequency) {
|
|
271
|
-
return
|
|
520
|
+
return mul(frequency, 24);
|
|
272
521
|
}
|
|
273
522
|
/**
|
|
274
523
|
* Convert {@link PerDay} to {@link PerHour}.
|
|
275
524
|
*/
|
|
276
525
|
function perDayToPerHour(frequency) {
|
|
277
|
-
return
|
|
526
|
+
return div(frequency, 24);
|
|
278
527
|
}
|
|
279
528
|
/**
|
|
280
529
|
* Convert {@link PerDay} to {@link PerWeek}.
|
|
281
530
|
*/
|
|
282
531
|
function perDayToPerWeek(frequency) {
|
|
283
|
-
return
|
|
532
|
+
return mul(frequency, 7);
|
|
284
533
|
}
|
|
285
534
|
/**
|
|
286
535
|
* Convert {@link PerDay} to {@link PerYear}.
|
|
@@ -289,13 +538,13 @@ function perDayToPerWeek(frequency) {
|
|
|
289
538
|
* Use an actual date/time library if you need more control.
|
|
290
539
|
*/
|
|
291
540
|
function perDayToPerYear(frequency) {
|
|
292
|
-
return
|
|
541
|
+
return mul(frequency, 365.25);
|
|
293
542
|
}
|
|
294
543
|
/**
|
|
295
544
|
* Convert {@link PerWeek} to {@link PerDay}.
|
|
296
545
|
*/
|
|
297
546
|
function perWeekToPerDay(frequency) {
|
|
298
|
-
return
|
|
547
|
+
return div(frequency, 7);
|
|
299
548
|
}
|
|
300
549
|
/**
|
|
301
550
|
* Convert {@link PerWeek} to {@link PerYear}.
|
|
@@ -310,7 +559,7 @@ function perWeekToPerYear(frequency) {
|
|
|
310
559
|
* Use an actual date/time library if you need more control.
|
|
311
560
|
*/
|
|
312
561
|
function perYearToPerDay(frequency) {
|
|
313
|
-
return
|
|
562
|
+
return div(frequency, 365.25);
|
|
314
563
|
}
|
|
315
564
|
/**
|
|
316
565
|
* Convert {@link PerYear} to {@link PerWeek}.
|
|
@@ -323,13 +572,13 @@ function perYearToPerWeek(frequency) {
|
|
|
323
572
|
* Convert {@link Gram} to {@link Tonne}.
|
|
324
573
|
*/
|
|
325
574
|
function gramsToTonnes(mass) {
|
|
326
|
-
return
|
|
575
|
+
return div(mass, 1_000_000);
|
|
327
576
|
}
|
|
328
577
|
/**
|
|
329
578
|
* Convert {@link Tonne} to {@link Gram}.
|
|
330
579
|
*/
|
|
331
580
|
function tonnesToGrams(mass) {
|
|
332
|
-
return
|
|
581
|
+
return mul(mass, 1_000_000);
|
|
333
582
|
}
|
|
334
583
|
|
|
335
584
|
/**
|
|
@@ -339,7 +588,7 @@ function tonnesToGrams(mass) {
|
|
|
339
588
|
* Convert `X` to `dekaX`.
|
|
340
589
|
*/
|
|
341
590
|
function toDeka(value) {
|
|
342
|
-
return
|
|
591
|
+
return mul(value, 10);
|
|
343
592
|
}
|
|
344
593
|
/**
|
|
345
594
|
* Convert `dekaX` to `X`.
|
|
@@ -349,7 +598,7 @@ const fromDeka = toDeci;
|
|
|
349
598
|
* Convert `X` to `deciX`.
|
|
350
599
|
*/
|
|
351
600
|
function toDeci(value) {
|
|
352
|
-
return
|
|
601
|
+
return div(value, 10);
|
|
353
602
|
}
|
|
354
603
|
/**
|
|
355
604
|
* Convert `deciX` to `X`.
|
|
@@ -359,7 +608,7 @@ const fromDeci = toDeka;
|
|
|
359
608
|
* Convert `X` to `hectoX`.
|
|
360
609
|
*/
|
|
361
610
|
function toHecto(value) {
|
|
362
|
-
return
|
|
611
|
+
return mul(value, 100);
|
|
363
612
|
}
|
|
364
613
|
/**
|
|
365
614
|
* Convert `hectoX` to `X`.
|
|
@@ -369,7 +618,7 @@ const fromHecto = toCenti;
|
|
|
369
618
|
* Convert `X` to `centiX`.
|
|
370
619
|
*/
|
|
371
620
|
function toCenti(value) {
|
|
372
|
-
return
|
|
621
|
+
return div(value, 100);
|
|
373
622
|
}
|
|
374
623
|
/**
|
|
375
624
|
* Convert `centiX` to `X`.
|
|
@@ -379,7 +628,7 @@ const fromCenti = toHecto;
|
|
|
379
628
|
* Convert `X` to `kiloX`.
|
|
380
629
|
*/
|
|
381
630
|
function toKilo(value) {
|
|
382
|
-
return
|
|
631
|
+
return mul(value, 1000);
|
|
383
632
|
}
|
|
384
633
|
/**
|
|
385
634
|
* Convert `kiloX` to `X`.
|
|
@@ -389,7 +638,7 @@ const fromKilo = toMilli;
|
|
|
389
638
|
* Convert `X` to `milliX`.
|
|
390
639
|
*/
|
|
391
640
|
function toMilli(value) {
|
|
392
|
-
return
|
|
641
|
+
return div(value, 1000);
|
|
393
642
|
}
|
|
394
643
|
/**
|
|
395
644
|
* Convert `milliX` to `X`.
|
|
@@ -399,7 +648,7 @@ const fromMilli = toKilo;
|
|
|
399
648
|
* Convert `X` to `megaX`.
|
|
400
649
|
*/
|
|
401
650
|
function toMega(value) {
|
|
402
|
-
return
|
|
651
|
+
return mul(value, 1000000);
|
|
403
652
|
}
|
|
404
653
|
/**
|
|
405
654
|
* Convert `megaX` to `X`.
|
|
@@ -409,7 +658,7 @@ const fromMega = toMicro;
|
|
|
409
658
|
* Convert `X` to `microX`.
|
|
410
659
|
*/
|
|
411
660
|
function toMicro(value) {
|
|
412
|
-
return
|
|
661
|
+
return div(value, 1000000);
|
|
413
662
|
}
|
|
414
663
|
/**
|
|
415
664
|
* Convert `microX` to `X`.
|
|
@@ -419,7 +668,7 @@ const fromMicro = toMega;
|
|
|
419
668
|
* Convert `X` to `gigaX`.
|
|
420
669
|
*/
|
|
421
670
|
function toGiga(value) {
|
|
422
|
-
return
|
|
671
|
+
return mul(value, 1000000000);
|
|
423
672
|
}
|
|
424
673
|
/**
|
|
425
674
|
* Convert `gigaX` to `X`.
|
|
@@ -429,7 +678,7 @@ const fromGiga = toNano;
|
|
|
429
678
|
* Convert `X` to `nanoX`.
|
|
430
679
|
*/
|
|
431
680
|
function toNano(value) {
|
|
432
|
-
return
|
|
681
|
+
return div(value, 1000000000);
|
|
433
682
|
}
|
|
434
683
|
/**
|
|
435
684
|
* Convert `nanoX` to `X`.
|
|
@@ -439,7 +688,7 @@ const fromNano = toGiga;
|
|
|
439
688
|
* Convert `X` to `teraX`.
|
|
440
689
|
*/
|
|
441
690
|
function toTera(value) {
|
|
442
|
-
return
|
|
691
|
+
return mul(value, 1000000000000);
|
|
443
692
|
}
|
|
444
693
|
/**
|
|
445
694
|
* Convert `teraX` to `X`.
|
|
@@ -449,7 +698,7 @@ const fromTera = toPico;
|
|
|
449
698
|
* Convert `X` to `picoX`.
|
|
450
699
|
*/
|
|
451
700
|
function toPico(value) {
|
|
452
|
-
return
|
|
701
|
+
return div(value, 1000000000000);
|
|
453
702
|
}
|
|
454
703
|
/**
|
|
455
704
|
* Convert `picoX` to `X`.
|
|
@@ -470,28 +719,43 @@ function kelvinToCelsius(temperature) {
|
|
|
470
719
|
}
|
|
471
720
|
|
|
472
721
|
/**
|
|
473
|
-
* Convert {@link Cubic}<{@link
|
|
722
|
+
* Convert {@link Cubic}<{@link Meter}> to {@link Liter}.
|
|
474
723
|
*/
|
|
475
|
-
function
|
|
476
|
-
return
|
|
724
|
+
function cubicMetersToLiters(volume) {
|
|
725
|
+
return mul(volume, 1000);
|
|
477
726
|
}
|
|
478
727
|
/**
|
|
479
|
-
* Convert {@link
|
|
728
|
+
* Convert {@link Liter} to {@link Cubic}<{@link Meter}>.
|
|
480
729
|
*/
|
|
481
|
-
function
|
|
482
|
-
return
|
|
730
|
+
function litersToCubicMeters(volume) {
|
|
731
|
+
return div(volume, 1000);
|
|
483
732
|
}
|
|
484
733
|
|
|
734
|
+
exports.abs = abs;
|
|
735
|
+
exports.acos = acos;
|
|
736
|
+
exports.acosh = acosh;
|
|
737
|
+
exports.add = add;
|
|
485
738
|
exports.aresToHectares = aresToHectares;
|
|
486
|
-
exports.
|
|
739
|
+
exports.aresToSquareMeters = aresToSquareMeters;
|
|
740
|
+
exports.asin = asin;
|
|
741
|
+
exports.asinh = asinh;
|
|
742
|
+
exports.atan = atan;
|
|
743
|
+
exports.atan2 = atan2;
|
|
744
|
+
exports.atanh = atanh;
|
|
745
|
+
exports.ceil = ceil;
|
|
487
746
|
exports.celsiusToKelvin = celsiusToKelvin;
|
|
488
|
-
exports.
|
|
747
|
+
exports.cos = cos;
|
|
748
|
+
exports.cosh = cosh;
|
|
749
|
+
exports.cubicMetersToLiters = cubicMetersToLiters;
|
|
489
750
|
exports.daysToHours = daysToHours;
|
|
490
751
|
exports.daysToWeeks = daysToWeeks;
|
|
491
752
|
exports.daysToYears = daysToYears;
|
|
492
753
|
exports.degreesToGradians = degreesToGradians;
|
|
493
754
|
exports.degreesToRadians = degreesToRadians;
|
|
494
755
|
exports.degreesToTurns = degreesToTurns;
|
|
756
|
+
exports.div = div;
|
|
757
|
+
exports.eq = eq;
|
|
758
|
+
exports.floor = floor;
|
|
495
759
|
exports.fromCenti = fromCenti;
|
|
496
760
|
exports.fromDeci = fromDeci;
|
|
497
761
|
exports.fromDeka = fromDeka;
|
|
@@ -508,19 +772,30 @@ exports.gradiansToDegrees = gradiansToDegrees;
|
|
|
508
772
|
exports.gradiansToRadians = gradiansToRadians;
|
|
509
773
|
exports.gradiansToTurns = gradiansToTurns;
|
|
510
774
|
exports.gramsToTonnes = gramsToTonnes;
|
|
775
|
+
exports.gt = gt;
|
|
776
|
+
exports.gte = gte;
|
|
511
777
|
exports.hectaresToAres = hectaresToAres;
|
|
512
|
-
exports.
|
|
778
|
+
exports.hectaresToSquareMeters = hectaresToSquareMeters;
|
|
513
779
|
exports.hertzToPerHour = hertzToPerHour;
|
|
514
780
|
exports.hertzToPerMinute = hertzToPerMinute;
|
|
515
781
|
exports.hoursToDays = hoursToDays;
|
|
516
782
|
exports.hoursToMinutes = hoursToMinutes;
|
|
517
783
|
exports.hoursToSeconds = hoursToSeconds;
|
|
784
|
+
exports.inverse = inverse;
|
|
518
785
|
exports.joulesToWattHours = joulesToWattHours;
|
|
519
786
|
exports.joulesToWattMinutes = joulesToWattMinutes;
|
|
520
787
|
exports.kelvinToCelsius = kelvinToCelsius;
|
|
521
|
-
exports.
|
|
788
|
+
exports.litersToCubicMeters = litersToCubicMeters;
|
|
789
|
+
exports.lt = lt;
|
|
790
|
+
exports.lte = lte;
|
|
791
|
+
exports.max = max;
|
|
792
|
+
exports.min = min;
|
|
522
793
|
exports.minutesToHours = minutesToHours;
|
|
523
794
|
exports.minutesToSeconds = minutesToSeconds;
|
|
795
|
+
exports.mod = mod;
|
|
796
|
+
exports.modSafe = modSafe;
|
|
797
|
+
exports.mul = mul;
|
|
798
|
+
exports.negate = negate;
|
|
524
799
|
exports.perDayToPerHour = perDayToPerHour;
|
|
525
800
|
exports.perDayToPerWeek = perDayToPerWeek;
|
|
526
801
|
exports.perDayToPerYear = perDayToPerYear;
|
|
@@ -533,13 +808,23 @@ exports.perWeekToPerDay = perWeekToPerDay;
|
|
|
533
808
|
exports.perWeekToPerYear = perWeekToPerYear;
|
|
534
809
|
exports.perYearToPerDay = perYearToPerDay;
|
|
535
810
|
exports.perYearToPerWeek = perYearToPerWeek;
|
|
811
|
+
exports.pow = pow;
|
|
536
812
|
exports.radiansToDegrees = radiansToDegrees;
|
|
537
813
|
exports.radiansToGradians = radiansToGradians;
|
|
538
814
|
exports.radiansToTurns = radiansToTurns;
|
|
815
|
+
exports.root = root;
|
|
816
|
+
exports.round = round;
|
|
539
817
|
exports.secondsToHours = secondsToHours;
|
|
540
818
|
exports.secondsToMinutes = secondsToMinutes;
|
|
541
|
-
exports.
|
|
542
|
-
exports.
|
|
819
|
+
exports.sin = sin;
|
|
820
|
+
exports.sinh = sinh;
|
|
821
|
+
exports.sqrt = sqrt;
|
|
822
|
+
exports.squareMetersToAres = squareMetersToAres;
|
|
823
|
+
exports.squareMetersToHectares = squareMetersToHectares;
|
|
824
|
+
exports.sub = sub;
|
|
825
|
+
exports.sum = sum;
|
|
826
|
+
exports.tan = tan;
|
|
827
|
+
exports.tanh = tanh;
|
|
543
828
|
exports.toCenti = toCenti;
|
|
544
829
|
exports.toDeci = toDeci;
|
|
545
830
|
exports.toDeka = toDeka;
|