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,125 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @module uom-types/functions/higher-order
5
- */
6
- /**
7
- * Add two values with the same units together.
8
- *
9
- * @category Math
10
- */
11
- function add(a) {
12
- return (b) => (b + a);
13
- }
14
- /**
15
- * Subtract one value from another with the same units.
16
- *
17
- * @category Math
18
- */
19
- function sub(a) {
20
- return (b) => (b - a);
21
- }
22
- /**
23
- * Multiple a value by the given value.
24
- *
25
- * @category Math
26
- */
27
- function mul(a) {
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return -- Casting to actual type fails for some reason.
29
- return (b) => (b * a);
30
- }
31
- /**
32
- * Divide one value by the given value.
33
- *
34
- * @category Math
35
- */
36
- function div(a) {
37
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return -- Casting to actual type fails for some reason.
38
- return (b) => (b / a);
39
- }
40
- /**
41
- * Modulo operator.
42
- *
43
- * @category Math
44
- */
45
- function mod(a) {
46
- return (b) => (b % a);
47
- }
48
- /**
49
- * Perform mathematic modular arithmetic.
50
- *
51
- * @category Math
52
- */
53
- function modSafe(a) {
54
- return (b) => (((b % a) + a) % a);
55
- }
56
- /**
57
- * Put a number to the power of the given value.
58
- *
59
- * @category Math
60
- */
61
- function pow(exponent) {
62
- return (base) => (base ** exponent);
63
- }
64
- /**
65
- * Take the nth root of a number.
66
- *
67
- * @category Math
68
- */
69
- function root(exponent) {
70
- return (base) => (base ** (1 / exponent));
71
- }
72
- /**
73
- * Equal: Compare if a value is equal to the given value.
74
- *
75
- * @category Math
76
- */
77
- function eq(a) {
78
- return (b) => b === a;
79
- }
80
- /**
81
- * Greater Than: Compare if a value is greater than the given value.
82
- *
83
- * @category Math
84
- */
85
- function gt(a) {
86
- return (b) => b > a;
87
- }
88
- /**
89
- * Greater Than or Equal: Compare if a value is greater than or equal to the given value.
90
- *
91
- * @category Math
92
- */
93
- function gte(a) {
94
- return (b) => b >= a;
95
- }
96
- /**
97
- * Less Than: Compare if a value is less than the given value.
98
- *
99
- * @category Math
100
- */
101
- function lt(a) {
102
- return (b) => b < a;
103
- }
104
- /**
105
- * Less Than or Equal: Compare if a value is less than or equal to the given value.
106
- *
107
- * @category Math
108
- */
109
- function lte(a) {
110
- return (b) => b <= a;
111
- }
112
-
113
- exports.add = add;
114
- exports.div = div;
115
- exports.eq = eq;
116
- exports.gt = gt;
117
- exports.gte = gte;
118
- exports.lt = lt;
119
- exports.lte = lte;
120
- exports.mod = mod;
121
- exports.modSafe = modSafe;
122
- exports.mul = mul;
123
- exports.pow = pow;
124
- exports.root = root;
125
- exports.sub = sub;
@@ -1,91 +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 } from './_units.cjs';
2
-
3
- /**
4
- * @module uom-types/functions/higher-order
5
- */
6
-
7
- type OperationIO<T extends number> = [T] extends [
8
- UnknownUnit | UnknownAbstractUnit
9
- ] ? T : number;
10
- /**
11
- * Add two values with the same units together.
12
- *
13
- * @category Math
14
- */
15
- declare function add<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
16
- /**
17
- * Subtract one value from another with the same units.
18
- *
19
- * @category Math
20
- */
21
- declare function sub<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
22
- /**
23
- * Multiple a value by the given value.
24
- *
25
- * @category Math
26
- */
27
- declare function mul<A extends number>(a: A): <B extends number>(b: B) => Multiply<B, A>;
28
- /**
29
- * Divide one value by the given value.
30
- *
31
- * @category Math
32
- */
33
- declare function div<A extends number>(a: A): <B extends number>(b: B) => Divide<B, A>;
34
- /**
35
- * Modulo operator.
36
- *
37
- * @category Math
38
- */
39
- declare function mod<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
40
- /**
41
- * Perform mathematic modular arithmetic.
42
- *
43
- * @category Math
44
- */
45
- declare function modSafe<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
46
- type PowFunction<E extends number, B extends number> = E extends UnknownUnit ? never : E extends UnknownAbstractUnit ? never : E extends Exponent ? (b: B) => Pow<B, E> : E extends 0.5 ? (b: B) => Root<B, 2> : (b: B) => number;
47
- /**
48
- * Put a number to the power of the given value.
49
- *
50
- * @category Math
51
- */
52
- declare function pow<E extends number>(exponent: E): <B extends number>(base: Parameters<PowFunction<E, B>>[0]) => ReturnType<PowFunction<E, B>>;
53
- type RootFunction<E extends number, B extends number> = E extends UnknownUnit ? never : E extends UnknownAbstractUnit ? never : E extends PosExponent ? (b: B) => Root<B, E> : (b: B) => number;
54
- /**
55
- * Take the nth root of a number.
56
- *
57
- * @category Math
58
- */
59
- declare function root<N extends number>(exponent: N): <B extends number>(base: Parameters<RootFunction<N, B>>[0]) => ReturnType<RootFunction<N, B>>;
60
- /**
61
- * Equal: Compare if a value is equal to the given value.
62
- *
63
- * @category Math
64
- */
65
- declare function eq<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
66
- /**
67
- * Greater Than: Compare if a value is greater than the given value.
68
- *
69
- * @category Math
70
- */
71
- declare function gt<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
72
- /**
73
- * Greater Than or Equal: Compare if a value is greater than or equal to the given value.
74
- *
75
- * @category Math
76
- */
77
- declare function gte<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
78
- /**
79
- * Less Than: Compare if a value is less than the given value.
80
- *
81
- * @category Math
82
- */
83
- declare function lt<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
84
- /**
85
- * Less Than or Equal: Compare if a value is less than or equal to the given value.
86
- *
87
- * @category Math
88
- */
89
- declare function lte<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
90
-
91
- export { add, div, eq, gt, gte, lt, lte, mod, modSafe, mul, pow, root, sub };
@@ -1,91 +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 } from './_units.mjs';
2
-
3
- /**
4
- * @module uom-types/functions/higher-order
5
- */
6
-
7
- type OperationIO<T extends number> = [T] extends [
8
- UnknownUnit | UnknownAbstractUnit
9
- ] ? T : number;
10
- /**
11
- * Add two values with the same units together.
12
- *
13
- * @category Math
14
- */
15
- declare function add<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
16
- /**
17
- * Subtract one value from another with the same units.
18
- *
19
- * @category Math
20
- */
21
- declare function sub<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
22
- /**
23
- * Multiple a value by the given value.
24
- *
25
- * @category Math
26
- */
27
- declare function mul<A extends number>(a: A): <B extends number>(b: B) => Multiply<B, A>;
28
- /**
29
- * Divide one value by the given value.
30
- *
31
- * @category Math
32
- */
33
- declare function div<A extends number>(a: A): <B extends number>(b: B) => Divide<B, A>;
34
- /**
35
- * Modulo operator.
36
- *
37
- * @category Math
38
- */
39
- declare function mod<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
40
- /**
41
- * Perform mathematic modular arithmetic.
42
- *
43
- * @category Math
44
- */
45
- declare function modSafe<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => OperationIO<T>;
46
- type PowFunction<E extends number, B extends number> = E extends UnknownUnit ? never : E extends UnknownAbstractUnit ? never : E extends Exponent ? (b: B) => Pow<B, E> : E extends 0.5 ? (b: B) => Root<B, 2> : (b: B) => number;
47
- /**
48
- * Put a number to the power of the given value.
49
- *
50
- * @category Math
51
- */
52
- declare function pow<E extends number>(exponent: E): <B extends number>(base: Parameters<PowFunction<E, B>>[0]) => ReturnType<PowFunction<E, B>>;
53
- type RootFunction<E extends number, B extends number> = E extends UnknownUnit ? never : E extends UnknownAbstractUnit ? never : E extends PosExponent ? (b: B) => Root<B, E> : (b: B) => number;
54
- /**
55
- * Take the nth root of a number.
56
- *
57
- * @category Math
58
- */
59
- declare function root<N extends number>(exponent: N): <B extends number>(base: Parameters<RootFunction<N, B>>[0]) => ReturnType<RootFunction<N, B>>;
60
- /**
61
- * Equal: Compare if a value is equal to the given value.
62
- *
63
- * @category Math
64
- */
65
- declare function eq<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
66
- /**
67
- * Greater Than: Compare if a value is greater than the given value.
68
- *
69
- * @category Math
70
- */
71
- declare function gt<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
72
- /**
73
- * Greater Than or Equal: Compare if a value is greater than or equal to the given value.
74
- *
75
- * @category Math
76
- */
77
- declare function gte<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
78
- /**
79
- * Less Than: Compare if a value is less than the given value.
80
- *
81
- * @category Math
82
- */
83
- declare function lt<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
84
- /**
85
- * Less Than or Equal: Compare if a value is less than or equal to the given value.
86
- *
87
- * @category Math
88
- */
89
- declare function lte<T extends number>(a: OperationIO<T>): (b: OperationIO<T>) => boolean;
90
-
91
- export { add, div, eq, gt, gte, lt, lte, mod, modSafe, mul, pow, root, sub };
@@ -1,111 +0,0 @@
1
- /**
2
- * @module uom-types/functions/higher-order
3
- */
4
- /**
5
- * Add two values with the same units together.
6
- *
7
- * @category Math
8
- */
9
- function add(a) {
10
- return (b) => (b + a);
11
- }
12
- /**
13
- * Subtract one value from another with the same units.
14
- *
15
- * @category Math
16
- */
17
- function sub(a) {
18
- return (b) => (b - a);
19
- }
20
- /**
21
- * Multiple a value by the given value.
22
- *
23
- * @category Math
24
- */
25
- function mul(a) {
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return -- Casting to actual type fails for some reason.
27
- return (b) => (b * a);
28
- }
29
- /**
30
- * Divide one value by the given value.
31
- *
32
- * @category Math
33
- */
34
- function div(a) {
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return -- Casting to actual type fails for some reason.
36
- return (b) => (b / a);
37
- }
38
- /**
39
- * Modulo operator.
40
- *
41
- * @category Math
42
- */
43
- function mod(a) {
44
- return (b) => (b % a);
45
- }
46
- /**
47
- * Perform mathematic modular arithmetic.
48
- *
49
- * @category Math
50
- */
51
- function modSafe(a) {
52
- return (b) => (((b % a) + a) % a);
53
- }
54
- /**
55
- * Put a number to the power of the given value.
56
- *
57
- * @category Math
58
- */
59
- function pow(exponent) {
60
- return (base) => (base ** exponent);
61
- }
62
- /**
63
- * Take the nth root of a number.
64
- *
65
- * @category Math
66
- */
67
- function root(exponent) {
68
- return (base) => (base ** (1 / exponent));
69
- }
70
- /**
71
- * Equal: Compare if a value is equal to the given value.
72
- *
73
- * @category Math
74
- */
75
- function eq(a) {
76
- return (b) => b === a;
77
- }
78
- /**
79
- * Greater Than: Compare if a value is greater than the given value.
80
- *
81
- * @category Math
82
- */
83
- function gt(a) {
84
- return (b) => b > a;
85
- }
86
- /**
87
- * Greater Than or Equal: Compare if a value is greater than or equal to the given value.
88
- *
89
- * @category Math
90
- */
91
- function gte(a) {
92
- return (b) => b >= a;
93
- }
94
- /**
95
- * Less Than: Compare if a value is less than the given value.
96
- *
97
- * @category Math
98
- */
99
- function lt(a) {
100
- return (b) => b < a;
101
- }
102
- /**
103
- * Less Than or Equal: Compare if a value is less than or equal to the given value.
104
- *
105
- * @category Math
106
- */
107
- function lte(a) {
108
- return (b) => b <= a;
109
- }
110
-
111
- export { add, div, eq, gt, gte, lt, lte, mod, modSafe, mul, pow, root, sub };