uom-types 3.1.1 → 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.
@@ -1,333 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @module uom-types/functions
5
- */
6
- /**
7
- * Add two values with the same units together.
8
- *
9
- * @category Math
10
- */
11
- function add(a, b) {
12
- return (a + b);
13
- }
14
- /**
15
- * Subtract one value from another with the same units.
16
- *
17
- * @category Math
18
- */
19
- function sub(a, b) {
20
- return (a - b);
21
- }
22
- /**
23
- * Multiple two values together.
24
- *
25
- * @category Math
26
- */
27
- function mul(a, b) {
28
- return (a * b);
29
- }
30
- /**
31
- * Divide one value by another.
32
- *
33
- * @category Math
34
- */
35
- function div(a, b) {
36
- return (a / b);
37
- }
38
- /**
39
- * Modulo operator.
40
- *
41
- * @category Math
42
- * @param a - Must be an integer.
43
- * @param b - Must be an integer.
44
- * @returns `a % b`
45
- */
46
- function mod(a, b) {
47
- return (a % b);
48
- }
49
- /**
50
- * Perform mathematic modular arithmetic.
51
- *
52
- * @category Math
53
- * @param a - Must be an integer.
54
- * @param b - Must be a positive integer.
55
- * @returns An integer between zero (inclusive) and `b` (exclusive).
56
- */
57
- function modSafe(a, b) {
58
- return (((a % b) + b) % b);
59
- }
60
- function pow(base, exponent) {
61
- return base ** exponent;
62
- }
63
- /**
64
- * Take the nth root of a number.
65
- *
66
- * @category Math
67
- */
68
- function root(base, exponent) {
69
- return (base ** (1 / exponent));
70
- }
71
- /**
72
- * Take the square root of the given value.
73
- *
74
- * @category Math
75
- */
76
- function sqrt(value) {
77
- return root(value, 2);
78
- }
79
- /**
80
- * Inverse the given value.
81
- *
82
- * @category Math
83
- */
84
- function inverse(value) {
85
- return pow(value, -1);
86
- }
87
- /**
88
- * Returns the negative of the given value.
89
- *
90
- * @category Math
91
- */
92
- function negate(value) {
93
- return -value;
94
- }
95
- /**
96
- * Returns the absolute value of the given value.
97
- *
98
- * @category Math
99
- */
100
- function abs(value) {
101
- return Math.abs(value);
102
- }
103
- /**
104
- * Returns the greatest integer less than or equal to the given value.
105
- *
106
- * @category Math
107
- */
108
- function floor(value) {
109
- return Math.floor(value);
110
- }
111
- /**
112
- * Returns the smallest integer greater than or equal the given value.
113
- *
114
- * @category Math
115
- */
116
- function ceil(value) {
117
- return Math.ceil(value);
118
- }
119
- /**
120
- * Returns the given value rounded to the nearest integer.
121
- *
122
- * @category Math
123
- */
124
- function round(value) {
125
- return Math.round(value);
126
- }
127
- /**
128
- * Returns the larger value in the given collection.
129
- *
130
- * @category Math
131
- */
132
- function max(values) {
133
- return Math.max(...values);
134
- }
135
- /**
136
- * Returns the smallest value in the given collection.
137
- *
138
- * @category Math
139
- */
140
- function min(values) {
141
- return Math.min(...values);
142
- }
143
- /**
144
- * Takes the sum of all the values in the given collection.
145
- *
146
- * @category Math
147
- */
148
- function sum(values) {
149
- return [...values].reduce(add, 0);
150
- }
151
- /**
152
- * Equal: Compare if two values are equal.
153
- *
154
- * @category Math
155
- */
156
- function eq(a, b) {
157
- return a === b;
158
- }
159
- /**
160
- * Greater Than: Compare if the first value is greater than the second.
161
- *
162
- * @category Math
163
- */
164
- function gt(a, b) {
165
- return a > b;
166
- }
167
- /**
168
- * Greater Than or Equal: Compare if the first value is greater than or equal to the second.
169
- *
170
- * @category Math
171
- */
172
- function gte(a, b) {
173
- return a >= b;
174
- }
175
- /**
176
- * Less Than: Compare if the first value is less than the second.
177
- *
178
- * @category Math
179
- */
180
- function lt(a, b) {
181
- return a < b;
182
- }
183
- /**
184
- * Less Than or Equal: Compare if the first value is less than or equal to the second.
185
- *
186
- * @category Math
187
- */
188
- function lte(a, b) {
189
- return a <= b;
190
- }
191
- /**
192
- * Returns the sine of a number.
193
- *
194
- * @category Math
195
- */
196
- function sin(angle) {
197
- return Math.sin(angle);
198
- }
199
- /**
200
- * Returns the cosine of a number.
201
- *
202
- * @category Math
203
- */
204
- function cos(angle) {
205
- return Math.cos(angle);
206
- }
207
- /**
208
- * Returns the tangent of a number.
209
- *
210
- * @category Math
211
- */
212
- function tan(angle) {
213
- return Math.tan(angle);
214
- }
215
- /**
216
- * Returns the arcsine of a number.
217
- *
218
- * @category Math
219
- */
220
- function asin(value) {
221
- return Math.asin(value);
222
- }
223
- /**
224
- * Returns the arc cosine (or inverse cosine) of a number.
225
- *
226
- * @category Math
227
- */
228
- function acos(value) {
229
- return Math.acos(value);
230
- }
231
- /**
232
- * Returns the arctangent of a number.
233
- *
234
- * @category Math
235
- */
236
- function atan(value) {
237
- return Math.atan(value);
238
- }
239
- /**
240
- * Returns the angle (in radians) from the X axis to a point.
241
- *
242
- * @category Math
243
- * @param x - A number representing the cartesian x-coordinate.
244
- * @param y - A number representing the cartesian y-coordinate.
245
- */
246
- function atan2(x, y) {
247
- return Math.atan2(x, y);
248
- }
249
- /**
250
- * Returns the hyperbolic sine of a number.
251
- *
252
- * @category Math
253
- */
254
- function sinh(angle) {
255
- return Math.sinh(angle);
256
- }
257
- /**
258
- * Returns the hyperbolic cosine of a number.
259
- *
260
- * @category Math
261
- */
262
- function cosh(angle) {
263
- return Math.cosh(angle);
264
- }
265
- /**
266
- * Returns the hyperbolic tangent of a number.
267
- *
268
- * @category Math
269
- */
270
- function tanh(angle) {
271
- return Math.tanh(angle);
272
- }
273
- /**
274
- * Returns the inverse hyperbolic sine of a number.
275
- *
276
- * @category Math
277
- */
278
- function asinh(value) {
279
- return Math.asinh(value);
280
- }
281
- /**
282
- * Returns the inverse hyperbolic cosine of a number.
283
- *
284
- * @category Math
285
- */
286
- function acosh(value) {
287
- return Math.acosh(value);
288
- }
289
- /**
290
- * Returns the inverse hyperbolic tangent of a number.
291
- *
292
- * @category Math
293
- */
294
- function atanh(value) {
295
- return Math.atanh(value);
296
- }
297
-
298
- exports.abs = abs;
299
- exports.acos = acos;
300
- exports.acosh = acosh;
301
- exports.add = add;
302
- exports.asin = asin;
303
- exports.asinh = asinh;
304
- exports.atan = atan;
305
- exports.atan2 = atan2;
306
- exports.atanh = atanh;
307
- exports.ceil = ceil;
308
- exports.cos = cos;
309
- exports.cosh = cosh;
310
- exports.div = div;
311
- exports.eq = eq;
312
- exports.floor = floor;
313
- exports.gt = gt;
314
- exports.gte = gte;
315
- exports.inverse = inverse;
316
- exports.lt = lt;
317
- exports.lte = lte;
318
- exports.max = max;
319
- exports.min = min;
320
- exports.mod = mod;
321
- exports.modSafe = modSafe;
322
- exports.mul = mul;
323
- exports.negate = negate;
324
- exports.pow = pow;
325
- exports.root = root;
326
- exports.round = round;
327
- exports.sin = sin;
328
- exports.sinh = sinh;
329
- exports.sqrt = sqrt;
330
- exports.sub = sub;
331
- exports.sum = sum;
332
- exports.tan = tan;
333
- exports.tanh = tanh;
@@ -1,243 +0,0 @@
1
- import { t as Multiply, q as Divide, i as UnknownUnit, h as UnknownAbstractUnit, E as Exponent, P as Pow, R as Root, o as PosExponent, I as Inverse } from './_units.cjs';
2
- import { R as Radian } from './_angle-plane.cjs';
3
- import { U as Unitless } from './_identity.cjs';
4
-
5
- /**
6
- * @module uom-types/functions
7
- */
8
-
9
- type OperationIO<T extends number> = [T] extends [
10
- UnknownUnit | UnknownAbstractUnit
11
- ] ? T : number;
12
- /**
13
- * Add two values with the same units together.
14
- *
15
- * @category Math
16
- */
17
- declare function add<T extends number>(a: OperationIO<T>, b: OperationIO<T>): OperationIO<T>;
18
- /**
19
- * Subtract one value from another with the same units.
20
- *
21
- * @category Math
22
- */
23
- declare function sub<T extends number>(a: OperationIO<T>, b: OperationIO<T>): OperationIO<T>;
24
- /**
25
- * Multiple two values together.
26
- *
27
- * @category Math
28
- */
29
- declare function mul<A extends number, B extends number>(a: A, b: B): Multiply<A, B>;
30
- /**
31
- * Divide one value by another.
32
- *
33
- * @category Math
34
- */
35
- declare function div<A extends number, B extends number>(a: A, b: B): Divide<A, B>;
36
- /**
37
- * Modulo operator.
38
- *
39
- * @category Math
40
- * @param a - Must be an integer.
41
- * @param b - Must be an integer.
42
- * @returns `a % b`
43
- */
44
- declare function mod<T extends number>(a: OperationIO<T>, b: OperationIO<T>): OperationIO<T>;
45
- /**
46
- * Perform mathematic modular arithmetic.
47
- *
48
- * @category Math
49
- * @param a - Must be an integer.
50
- * @param b - Must be a positive integer.
51
- * @returns An integer between zero (inclusive) and `b` (exclusive).
52
- */
53
- declare function modSafe<T extends number>(a: OperationIO<T>, b: OperationIO<T>): OperationIO<T>;
54
- /**
55
- * Raise a number to the power of another.
56
- *
57
- * @category Math
58
- */
59
- declare function pow<B extends number, E extends number>(base: B, exponent: E extends UnknownUnit ? never : E extends UnknownAbstractUnit ? never : E): E extends Exponent ? Pow<B, E> : number;
60
- /**
61
- * Put a number to the power of 1/2.
62
- *
63
- * @category Math
64
- */
65
- declare function pow<B extends number>(base: B, exponent: 0.5): Root<B, 2>;
66
- /**
67
- * Take the nth root of a number.
68
- *
69
- * @category Math
70
- */
71
- declare function root<B extends number, N extends number>(base: B, exponent: N extends UnknownUnit ? never : N extends UnknownAbstractUnit ? never : N): N extends PosExponent ? Root<B, N> : number;
72
- /**
73
- * Take the square root of the given value.
74
- *
75
- * @category Math
76
- */
77
- declare function sqrt<T extends number>(value: T): Root<T, 2>;
78
- /**
79
- * Inverse the given value.
80
- *
81
- * @category Math
82
- */
83
- declare function inverse<T extends number>(value: T): Inverse<T>;
84
- /**
85
- * Returns the negative of the given value.
86
- *
87
- * @category Math
88
- */
89
- declare function negate<T extends number>(value: OperationIO<T>): OperationIO<T>;
90
- /**
91
- * Returns the absolute value of the given value.
92
- *
93
- * @category Math
94
- */
95
- declare function abs<T extends number>(value: OperationIO<T>): OperationIO<T>;
96
- /**
97
- * Returns the greatest integer less than or equal to the given value.
98
- *
99
- * @category Math
100
- */
101
- declare function floor<T extends number>(value: OperationIO<T>): OperationIO<T>;
102
- /**
103
- * Returns the smallest integer greater than or equal the given value.
104
- *
105
- * @category Math
106
- */
107
- declare function ceil<T extends number>(value: OperationIO<T>): OperationIO<T>;
108
- /**
109
- * Returns the given value rounded to the nearest integer.
110
- *
111
- * @category Math
112
- */
113
- declare function round<T extends number>(value: OperationIO<T>): OperationIO<T>;
114
- /**
115
- * Returns the larger value in the given collection.
116
- *
117
- * @category Math
118
- */
119
- declare function max<T extends number>(values: Iterable<T>): OperationIO<T>;
120
- /**
121
- * Returns the smallest value in the given collection.
122
- *
123
- * @category Math
124
- */
125
- declare function min<T extends number>(values: Iterable<T>): OperationIO<T>;
126
- /**
127
- * Takes the sum of all the values in the given collection.
128
- *
129
- * @category Math
130
- */
131
- declare function sum<T extends number>(values: Iterable<T>): OperationIO<T>;
132
- /**
133
- * Equal: Compare if two values are equal.
134
- *
135
- * @category Math
136
- */
137
- declare function eq<T extends number>(a: OperationIO<T>, b: OperationIO<T>): boolean;
138
- /**
139
- * Greater Than: Compare if the first value is greater than the second.
140
- *
141
- * @category Math
142
- */
143
- declare function gt<T extends number>(a: OperationIO<T>, b: OperationIO<T>): boolean;
144
- /**
145
- * Greater Than or Equal: Compare if the first value is greater than or equal to the second.
146
- *
147
- * @category Math
148
- */
149
- declare function gte<T extends number>(a: OperationIO<T>, b: OperationIO<T>): boolean;
150
- /**
151
- * Less Than: Compare if the first value is less than the second.
152
- *
153
- * @category Math
154
- */
155
- declare function lt<T extends number>(a: OperationIO<T>, b: OperationIO<T>): boolean;
156
- /**
157
- * Less Than or Equal: Compare if the first value is less than or equal to the second.
158
- *
159
- * @category Math
160
- */
161
- declare function lte<T extends number>(a: OperationIO<T>, b: OperationIO<T>): boolean;
162
- /**
163
- * Returns the sine of a number.
164
- *
165
- * @category Math
166
- */
167
- declare function sin(angle: Radian): Unitless;
168
- /**
169
- * Returns the cosine of a number.
170
- *
171
- * @category Math
172
- */
173
- declare function cos(angle: Radian): Unitless;
174
- /**
175
- * Returns the tangent of a number.
176
- *
177
- * @category Math
178
- */
179
- declare function tan(angle: Radian): Unitless;
180
- /**
181
- * Returns the arcsine of a number.
182
- *
183
- * @category Math
184
- */
185
- declare function asin(value: Unitless): Radian;
186
- /**
187
- * Returns the arc cosine (or inverse cosine) of a number.
188
- *
189
- * @category Math
190
- */
191
- declare function acos(value: Unitless): Radian;
192
- /**
193
- * Returns the arctangent of a number.
194
- *
195
- * @category Math
196
- */
197
- declare function atan(value: Unitless): Radian;
198
- /**
199
- * Returns the angle (in radians) from the X axis to a point.
200
- *
201
- * @category Math
202
- * @param x - A number representing the cartesian x-coordinate.
203
- * @param y - A number representing the cartesian y-coordinate.
204
- */
205
- declare function atan2<T extends number>(x: T, y: T): Radian;
206
- /**
207
- * Returns the hyperbolic sine of a number.
208
- *
209
- * @category Math
210
- */
211
- declare function sinh(angle: Radian): Unitless;
212
- /**
213
- * Returns the hyperbolic cosine of a number.
214
- *
215
- * @category Math
216
- */
217
- declare function cosh(angle: Radian): Unitless;
218
- /**
219
- * Returns the hyperbolic tangent of a number.
220
- *
221
- * @category Math
222
- */
223
- declare function tanh(angle: Radian): Unitless;
224
- /**
225
- * Returns the inverse hyperbolic sine of a number.
226
- *
227
- * @category Math
228
- */
229
- declare function asinh(value: Unitless): Radian;
230
- /**
231
- * Returns the inverse hyperbolic cosine of a number.
232
- *
233
- * @category Math
234
- */
235
- declare function acosh(value: Unitless): Radian;
236
- /**
237
- * Returns the inverse hyperbolic tangent of a number.
238
- *
239
- * @category Math
240
- */
241
- declare function atanh(value: Unitless): Radian;
242
-
243
- export { abs, acos, acosh, add, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, div, eq, floor, gt, gte, inverse, lt, lte, max, min, mod, modSafe, mul, negate, pow, root, round, sin, sinh, sqrt, sub, sum, tan, tanh };