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