uom-types 0.1.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/LICENSE +29 -0
- package/README.md +37 -0
- package/dist/functions-ho.cjs +94 -0
- package/dist/functions-ho.d.cts +58 -0
- package/dist/functions-ho.d.mts +58 -0
- package/dist/functions-ho.mjs +80 -0
- package/dist/functions.cjs +169 -0
- package/dist/functions.d.cts +133 -0
- package/dist/functions.d.mts +133 -0
- package/dist/functions.mjs +145 -0
- package/dist/index.d.cts +57 -0
- package/dist/index.d.mts +57 -0
- package/dist/si-units-converters.cjs +2 -0
- package/dist/si-units-converters.d.cts +2 -0
- package/dist/si-units-converters.d.mts +2 -0
- package/dist/si-units-converters.mjs +1 -0
- package/dist/si-units.d.cts +5 -0
- package/dist/si-units.d.mts +5 -0
- package/package.json +148 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Rebecca Stevens
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Units of Measure Types
|
|
4
|
+
|
|
5
|
+
Typesafe units with no runtime overhead.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/uom-types)
|
|
8
|
+
[](https://github.com/RebeccaStevens/uom-types/actions/workflows/release.yml)
|
|
9
|
+
[](https://codecov.io/gh/RebeccaStevens/uom-types)\
|
|
10
|
+
[](https://github.com/prettier/prettier)
|
|
11
|
+
[](https://github.com/RebeccaStevens/uom-types/discussions)
|
|
12
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
13
|
+
[](https://commitizen.github.io/cz-cli/)
|
|
14
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
## Donate
|
|
19
|
+
|
|
20
|
+
[Any donations would be much appreciated](./DONATIONS.md). 😄
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
# Install with npm
|
|
26
|
+
npm install -D uom-types
|
|
27
|
+
|
|
28
|
+
# Install with pnpm
|
|
29
|
+
pnpm add -D uom-types
|
|
30
|
+
|
|
31
|
+
# Install with yarn
|
|
32
|
+
yarn add -D uom-types
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Inspiration
|
|
36
|
+
|
|
37
|
+
Inspired by [uom-ts](https://github.com/mindbrave/uom-ts).
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Add a value by the given value.
|
|
5
|
+
*/
|
|
6
|
+
function add(a) {
|
|
7
|
+
return (b) => (a + b);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Subtract one value from the given value.
|
|
11
|
+
*/
|
|
12
|
+
function sub(a) {
|
|
13
|
+
return (b) => (b - a);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Multiple a value by the given value.
|
|
17
|
+
*/
|
|
18
|
+
function mul(a) {
|
|
19
|
+
return (b) => (a * b);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Divide one value by the given value.
|
|
23
|
+
*/
|
|
24
|
+
function div(a) {
|
|
25
|
+
return (b) => (b / a);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Modulo operator.
|
|
29
|
+
*/
|
|
30
|
+
function mod(a) {
|
|
31
|
+
return (b) => (b % a);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Perform mathematic modular arithmetic.
|
|
35
|
+
*/
|
|
36
|
+
function modSafe(a) {
|
|
37
|
+
return (b) => (((b % a) + a) % a);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Put a number to the power of the given value.
|
|
41
|
+
*/
|
|
42
|
+
function pow(a) {
|
|
43
|
+
return ((b) => b ** a);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Take the square root of the given value.
|
|
47
|
+
*/
|
|
48
|
+
function sqrt() {
|
|
49
|
+
return pow(0.5);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Equal: Compare if a value is equal to the given value.
|
|
53
|
+
*/
|
|
54
|
+
function eq(a) {
|
|
55
|
+
return (b) => b === a;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Greater Than: Compare if a value is greater than the given value.
|
|
59
|
+
*/
|
|
60
|
+
function gt(a) {
|
|
61
|
+
return (b) => b > a;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Greater Than or Equal: Compare if a value is greater than or equal to the given value.
|
|
65
|
+
*/
|
|
66
|
+
function gte(a) {
|
|
67
|
+
return (b) => b >= a;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Less Than: Compare if a value is less than the given value.
|
|
71
|
+
*/
|
|
72
|
+
function lt(a) {
|
|
73
|
+
return (b) => b < a;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Less Than or Equal: Compare if a value is less than or equal to the given value.
|
|
77
|
+
*/
|
|
78
|
+
function lte(a) {
|
|
79
|
+
return (b) => b <= a;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.add = add;
|
|
83
|
+
exports.div = div;
|
|
84
|
+
exports.eq = eq;
|
|
85
|
+
exports.gt = gt;
|
|
86
|
+
exports.gte = gte;
|
|
87
|
+
exports.lt = lt;
|
|
88
|
+
exports.lte = lte;
|
|
89
|
+
exports.mod = mod;
|
|
90
|
+
exports.modSafe = modSafe;
|
|
91
|
+
exports.mul = mul;
|
|
92
|
+
exports.pow = pow;
|
|
93
|
+
exports.sqrt = sqrt;
|
|
94
|
+
exports.sub = sub;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Divide, UnknownUnit, Inverse, Multiply } from '/home/rebec/dev/uom-types/src/base/index.ts';
|
|
2
|
+
|
|
3
|
+
type OperationResult<T extends number> = T extends UnknownUnit ? T : number;
|
|
4
|
+
/**
|
|
5
|
+
* Add a value by the given value.
|
|
6
|
+
*/
|
|
7
|
+
declare function add<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Subtract one value from the given value.
|
|
10
|
+
*/
|
|
11
|
+
declare function sub<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Multiple a value by the given value.
|
|
14
|
+
*/
|
|
15
|
+
declare function mul<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Divide one value by the given value.
|
|
18
|
+
*/
|
|
19
|
+
declare function div<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Modulo operator.
|
|
22
|
+
*/
|
|
23
|
+
declare function mod<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Perform mathematic modular arithmetic.
|
|
26
|
+
*/
|
|
27
|
+
declare function modSafe<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
28
|
+
type PowFunction<A extends number, B extends number> = A extends -1 ? (b: B) => OperationResult<Inverse<B>> : A extends 0 ? (b: B) => 1 : A extends 0.5 ? (b: B) => OperationResult<Divide<B, 2>> : A extends 1 ? (b: B) => B : A extends 2 ? (b: B) => OperationResult<Multiply<B, B>> : A extends 3 ? (b: B) => OperationResult<Multiply<B, Multiply<B, B>>> : A extends 4 ? (b: B) => OperationResult<Multiply<B, Multiply<B, Multiply<B, B>>>> : (b: B) => OperationResult<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Put a number to the power of the given value.
|
|
31
|
+
*/
|
|
32
|
+
declare function pow<A extends number, B extends number>(a: A): PowFunction<A, B>;
|
|
33
|
+
/**
|
|
34
|
+
* Take the square root of the given value.
|
|
35
|
+
*/
|
|
36
|
+
declare function sqrt<T extends number>(): (value: T) => OperationResult<Divide<T, 2>>;
|
|
37
|
+
/**
|
|
38
|
+
* Equal: Compare if a value is equal to the given value.
|
|
39
|
+
*/
|
|
40
|
+
declare function eq<A extends number>(a: A): (b: A) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Greater Than: Compare if a value is greater than the given value.
|
|
43
|
+
*/
|
|
44
|
+
declare function gt<A extends number>(a: A): (b: A) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Greater Than or Equal: Compare if a value is greater than or equal to the given value.
|
|
47
|
+
*/
|
|
48
|
+
declare function gte<A extends number>(a: A): (b: A) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Less Than: Compare if a value is less than the given value.
|
|
51
|
+
*/
|
|
52
|
+
declare function lt<A extends number>(a: A): (b: A) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Less Than or Equal: Compare if a value is less than or equal to the given value.
|
|
55
|
+
*/
|
|
56
|
+
declare function lte<A extends number>(a: A): (b: A) => boolean;
|
|
57
|
+
|
|
58
|
+
export { add, div, eq, gt, gte, lt, lte, mod, modSafe, mul, pow, sqrt, sub };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Divide, UnknownUnit, Inverse, Multiply } from '/home/rebec/dev/uom-types/src/base/index.ts';
|
|
2
|
+
|
|
3
|
+
type OperationResult<T extends number> = T extends UnknownUnit ? T : number;
|
|
4
|
+
/**
|
|
5
|
+
* Add a value by the given value.
|
|
6
|
+
*/
|
|
7
|
+
declare function add<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Subtract one value from the given value.
|
|
10
|
+
*/
|
|
11
|
+
declare function sub<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Multiple a value by the given value.
|
|
14
|
+
*/
|
|
15
|
+
declare function mul<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Divide one value by the given value.
|
|
18
|
+
*/
|
|
19
|
+
declare function div<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Modulo operator.
|
|
22
|
+
*/
|
|
23
|
+
declare function mod<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Perform mathematic modular arithmetic.
|
|
26
|
+
*/
|
|
27
|
+
declare function modSafe<T extends number>(a: T): (b: T) => OperationResult<T>;
|
|
28
|
+
type PowFunction<A extends number, B extends number> = A extends -1 ? (b: B) => OperationResult<Inverse<B>> : A extends 0 ? (b: B) => 1 : A extends 0.5 ? (b: B) => OperationResult<Divide<B, 2>> : A extends 1 ? (b: B) => B : A extends 2 ? (b: B) => OperationResult<Multiply<B, B>> : A extends 3 ? (b: B) => OperationResult<Multiply<B, Multiply<B, B>>> : A extends 4 ? (b: B) => OperationResult<Multiply<B, Multiply<B, Multiply<B, B>>>> : (b: B) => OperationResult<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Put a number to the power of the given value.
|
|
31
|
+
*/
|
|
32
|
+
declare function pow<A extends number, B extends number>(a: A): PowFunction<A, B>;
|
|
33
|
+
/**
|
|
34
|
+
* Take the square root of the given value.
|
|
35
|
+
*/
|
|
36
|
+
declare function sqrt<T extends number>(): (value: T) => OperationResult<Divide<T, 2>>;
|
|
37
|
+
/**
|
|
38
|
+
* Equal: Compare if a value is equal to the given value.
|
|
39
|
+
*/
|
|
40
|
+
declare function eq<A extends number>(a: A): (b: A) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Greater Than: Compare if a value is greater than the given value.
|
|
43
|
+
*/
|
|
44
|
+
declare function gt<A extends number>(a: A): (b: A) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Greater Than or Equal: Compare if a value is greater than or equal to the given value.
|
|
47
|
+
*/
|
|
48
|
+
declare function gte<A extends number>(a: A): (b: A) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Less Than: Compare if a value is less than the given value.
|
|
51
|
+
*/
|
|
52
|
+
declare function lt<A extends number>(a: A): (b: A) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Less Than or Equal: Compare if a value is less than or equal to the given value.
|
|
55
|
+
*/
|
|
56
|
+
declare function lte<A extends number>(a: A): (b: A) => boolean;
|
|
57
|
+
|
|
58
|
+
export { add, div, eq, gt, gte, lt, lte, mod, modSafe, mul, pow, sqrt, sub };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a value by the given value.
|
|
3
|
+
*/
|
|
4
|
+
function add(a) {
|
|
5
|
+
return (b) => (a + b);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Subtract one value from the given value.
|
|
9
|
+
*/
|
|
10
|
+
function sub(a) {
|
|
11
|
+
return (b) => (b - a);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Multiple a value by the given value.
|
|
15
|
+
*/
|
|
16
|
+
function mul(a) {
|
|
17
|
+
return (b) => (a * b);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Divide one value by the given value.
|
|
21
|
+
*/
|
|
22
|
+
function div(a) {
|
|
23
|
+
return (b) => (b / a);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Modulo operator.
|
|
27
|
+
*/
|
|
28
|
+
function mod(a) {
|
|
29
|
+
return (b) => (b % a);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Perform mathematic modular arithmetic.
|
|
33
|
+
*/
|
|
34
|
+
function modSafe(a) {
|
|
35
|
+
return (b) => (((b % a) + a) % a);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Put a number to the power of the given value.
|
|
39
|
+
*/
|
|
40
|
+
function pow(a) {
|
|
41
|
+
return ((b) => b ** a);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Take the square root of the given value.
|
|
45
|
+
*/
|
|
46
|
+
function sqrt() {
|
|
47
|
+
return pow(0.5);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Equal: Compare if a value is equal to the given value.
|
|
51
|
+
*/
|
|
52
|
+
function eq(a) {
|
|
53
|
+
return (b) => b === a;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Greater Than: Compare if a value is greater than the given value.
|
|
57
|
+
*/
|
|
58
|
+
function gt(a) {
|
|
59
|
+
return (b) => b > a;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Greater Than or Equal: Compare if a value is greater than or equal to the given value.
|
|
63
|
+
*/
|
|
64
|
+
function gte(a) {
|
|
65
|
+
return (b) => b >= a;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Less Than: Compare if a value is less than the given value.
|
|
69
|
+
*/
|
|
70
|
+
function lt(a) {
|
|
71
|
+
return (b) => b < a;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Less Than or Equal: Compare if a value is less than or equal to the given value.
|
|
75
|
+
*/
|
|
76
|
+
function lte(a) {
|
|
77
|
+
return (b) => b <= a;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { add, div, eq, gt, gte, lt, lte, mod, modSafe, mul, pow, sqrt, sub };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Add two values together.
|
|
5
|
+
*/
|
|
6
|
+
function add(a, b) {
|
|
7
|
+
return (a + b);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Subtract one value from another.
|
|
11
|
+
*/
|
|
12
|
+
function sub(a, b) {
|
|
13
|
+
return (a - b);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Multiple two values together.
|
|
17
|
+
*/
|
|
18
|
+
function mul(a, b) {
|
|
19
|
+
return (a * b);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Divide one value by another.
|
|
23
|
+
*/
|
|
24
|
+
function div(a, b) {
|
|
25
|
+
return (a / b);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Modulo operator.
|
|
29
|
+
*
|
|
30
|
+
* @param a - Must be an integer.
|
|
31
|
+
* @param b - Must be an integer.
|
|
32
|
+
* @returns `a % b`
|
|
33
|
+
*/
|
|
34
|
+
function mod(a, b) {
|
|
35
|
+
return (a % b);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Perform mathematic modular arithmetic.
|
|
39
|
+
*
|
|
40
|
+
* @param a - Must be an integer.
|
|
41
|
+
* @param b - Must be a positive integer.
|
|
42
|
+
* @returns An integer between zero (inclusive) and `b` (exclusive).
|
|
43
|
+
*/
|
|
44
|
+
function modSafe(a, b) {
|
|
45
|
+
return (((a % b) + b) % b);
|
|
46
|
+
}
|
|
47
|
+
function pow(a, b) {
|
|
48
|
+
return a ** b;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Take the square root of the given value.
|
|
52
|
+
*/
|
|
53
|
+
function sqrt(value) {
|
|
54
|
+
return pow(value, 0.5);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Inverse the given value.
|
|
58
|
+
*/
|
|
59
|
+
function inverse(value) {
|
|
60
|
+
return pow(value, -1);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Make the given value negative.
|
|
64
|
+
*/
|
|
65
|
+
function negate(value) {
|
|
66
|
+
return -value;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns the absolute value of a number.
|
|
70
|
+
*/
|
|
71
|
+
function abs(value) {
|
|
72
|
+
return Math.abs(value);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns the greatest integer less than or equal to the given value.
|
|
76
|
+
*/
|
|
77
|
+
function floor(value) {
|
|
78
|
+
return Math.floor(value);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the smallest integer greater than or equal the given value.
|
|
82
|
+
*/
|
|
83
|
+
function ceil(value) {
|
|
84
|
+
return Math.ceil(value);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns the given value rounded to the nearest integer.
|
|
88
|
+
*/
|
|
89
|
+
function round(value) {
|
|
90
|
+
return Math.round(value);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns the larger value in the given collection.
|
|
94
|
+
*/
|
|
95
|
+
function max(values) {
|
|
96
|
+
return Math.max(...values);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns the smallest value in the given collection.
|
|
100
|
+
*/
|
|
101
|
+
function min(values) {
|
|
102
|
+
return Math.min(...values);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Takes the sum of all the values in the given collection.
|
|
106
|
+
*/
|
|
107
|
+
function sum(values) {
|
|
108
|
+
return values.reduce(add, 0);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Takes the product of all the values in the given collection.
|
|
112
|
+
*/
|
|
113
|
+
function product(values) {
|
|
114
|
+
return values.reduce(mul, 1);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Equal: Compare if two values are equal.
|
|
118
|
+
*/
|
|
119
|
+
function eq(a, b) {
|
|
120
|
+
return a === b;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Greater Than: Compare if the first value is greater than the second.
|
|
124
|
+
*/
|
|
125
|
+
function gt(a, b) {
|
|
126
|
+
return a > b;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Greater Than or Equal: Compare if the first value is greater than or equal to the second.
|
|
130
|
+
*/
|
|
131
|
+
function gte(a, b) {
|
|
132
|
+
return a >= b;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Less Than: Compare if the first value is less than the second.
|
|
136
|
+
*/
|
|
137
|
+
function lt(a, b) {
|
|
138
|
+
return a < b;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Less Than or Equal: Compare if the first value is less than or equal to the second.
|
|
142
|
+
*/
|
|
143
|
+
function lte(a, b) {
|
|
144
|
+
return a <= b;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
exports.abs = abs;
|
|
148
|
+
exports.add = add;
|
|
149
|
+
exports.ceil = ceil;
|
|
150
|
+
exports.div = div;
|
|
151
|
+
exports.eq = eq;
|
|
152
|
+
exports.floor = floor;
|
|
153
|
+
exports.gt = gt;
|
|
154
|
+
exports.gte = gte;
|
|
155
|
+
exports.inverse = inverse;
|
|
156
|
+
exports.lt = lt;
|
|
157
|
+
exports.lte = lte;
|
|
158
|
+
exports.max = max;
|
|
159
|
+
exports.min = min;
|
|
160
|
+
exports.mod = mod;
|
|
161
|
+
exports.modSafe = modSafe;
|
|
162
|
+
exports.mul = mul;
|
|
163
|
+
exports.negate = negate;
|
|
164
|
+
exports.pow = pow;
|
|
165
|
+
exports.product = product;
|
|
166
|
+
exports.round = round;
|
|
167
|
+
exports.sqrt = sqrt;
|
|
168
|
+
exports.sub = sub;
|
|
169
|
+
exports.sum = sum;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Inverse, Divide, Multiply, UnknownUnit } from '/home/rebec/dev/uom-types/src/base/index.ts';
|
|
2
|
+
|
|
3
|
+
type OperationResult<T extends number> = T extends UnknownUnit ? T : number;
|
|
4
|
+
/**
|
|
5
|
+
* Add two values together.
|
|
6
|
+
*/
|
|
7
|
+
declare function add<T extends number>(a: T, b: T): OperationResult<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Subtract one value from another.
|
|
10
|
+
*/
|
|
11
|
+
declare function sub<T extends number>(a: T, b: T): OperationResult<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Multiple two values together.
|
|
14
|
+
*/
|
|
15
|
+
declare function mul<T extends number>(a: T, b: T): OperationResult<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Divide one value by another.
|
|
18
|
+
*/
|
|
19
|
+
declare function div<T extends number>(a: T, b: T): OperationResult<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Modulo operator.
|
|
22
|
+
*
|
|
23
|
+
* @param a - Must be an integer.
|
|
24
|
+
* @param b - Must be an integer.
|
|
25
|
+
* @returns `a % b`
|
|
26
|
+
*/
|
|
27
|
+
declare function mod<T extends number>(a: T, b: T): OperationResult<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Perform mathematic modular arithmetic.
|
|
30
|
+
*
|
|
31
|
+
* @param a - Must be an integer.
|
|
32
|
+
* @param b - Must be a positive integer.
|
|
33
|
+
* @returns An integer between zero (inclusive) and `b` (exclusive).
|
|
34
|
+
*/
|
|
35
|
+
declare function modSafe<T extends number>(a: T, b: T): OperationResult<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Put a number to the power of -1.
|
|
38
|
+
*/
|
|
39
|
+
declare function pow<T extends number>(a: T, b: -1): OperationResult<Inverse<T>>;
|
|
40
|
+
/**
|
|
41
|
+
* Put a number to the power of 0.
|
|
42
|
+
*/
|
|
43
|
+
declare function pow<T extends number>(a: T, b: 0): 1;
|
|
44
|
+
/**
|
|
45
|
+
* Put a number to the power of 1/2.
|
|
46
|
+
*/
|
|
47
|
+
declare function pow<T extends number>(a: T, b: 0.5): OperationResult<Divide<T, 2>>;
|
|
48
|
+
/**
|
|
49
|
+
* Put a number to the power of 1.
|
|
50
|
+
*/
|
|
51
|
+
declare function pow<T extends number>(a: T, b: 1): T;
|
|
52
|
+
/**
|
|
53
|
+
* Put a number to the power of 2.
|
|
54
|
+
*/
|
|
55
|
+
declare function pow<T extends number>(a: T, b: 2): OperationResult<Multiply<T, T>>;
|
|
56
|
+
/**
|
|
57
|
+
* Put a number to the power of 3.
|
|
58
|
+
*/
|
|
59
|
+
declare function pow<T extends number>(a: T, b: 3): OperationResult<Multiply<T, Multiply<T, T>>>;
|
|
60
|
+
/**
|
|
61
|
+
* Put a number to the power of 4.
|
|
62
|
+
*/
|
|
63
|
+
declare function pow<T extends number>(a: T, b: 4): OperationResult<Multiply<T, Multiply<T, Multiply<T, T>>>>;
|
|
64
|
+
/**
|
|
65
|
+
* Put one number to the power of the other.
|
|
66
|
+
*/
|
|
67
|
+
declare function pow<T extends number>(a: T, b: T): number;
|
|
68
|
+
/**
|
|
69
|
+
* Take the square root of the given value.
|
|
70
|
+
*/
|
|
71
|
+
declare function sqrt<T extends number>(value: T): OperationResult<Divide<T, 2>>;
|
|
72
|
+
/**
|
|
73
|
+
* Inverse the given value.
|
|
74
|
+
*/
|
|
75
|
+
declare function inverse<T extends number>(value: T): OperationResult<Inverse<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Make the given value negative.
|
|
78
|
+
*/
|
|
79
|
+
declare function negate<T extends number>(value: T): OperationResult<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the absolute value of a number.
|
|
82
|
+
*/
|
|
83
|
+
declare function abs<T extends number>(value: T): OperationResult<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the greatest integer less than or equal to the given value.
|
|
86
|
+
*/
|
|
87
|
+
declare function floor<T extends number>(value: T): OperationResult<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the smallest integer greater than or equal the given value.
|
|
90
|
+
*/
|
|
91
|
+
declare function ceil<T extends number>(value: T): OperationResult<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Returns the given value rounded to the nearest integer.
|
|
94
|
+
*/
|
|
95
|
+
declare function round<T extends number>(value: T): OperationResult<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the larger value in the given collection.
|
|
98
|
+
*/
|
|
99
|
+
declare function max<T extends number>(values: Iterable<T>): OperationResult<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the smallest value in the given collection.
|
|
102
|
+
*/
|
|
103
|
+
declare function min<T extends number>(values: Iterable<T>): OperationResult<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Takes the sum of all the values in the given collection.
|
|
106
|
+
*/
|
|
107
|
+
declare function sum<T extends number>(values: ReadonlyArray<T>): OperationResult<T>;
|
|
108
|
+
/**
|
|
109
|
+
* Takes the product of all the values in the given collection.
|
|
110
|
+
*/
|
|
111
|
+
declare function product<T extends number>(values: ReadonlyArray<T>): OperationResult<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Equal: Compare if two values are equal.
|
|
114
|
+
*/
|
|
115
|
+
declare function eq<A extends number>(a: A, b: A): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Greater Than: Compare if the first value is greater than the second.
|
|
118
|
+
*/
|
|
119
|
+
declare function gt<A extends number>(a: A, b: A): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Greater Than or Equal: Compare if the first value is greater than or equal to the second.
|
|
122
|
+
*/
|
|
123
|
+
declare function gte<A extends number>(a: A, b: A): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Less Than: Compare if the first value is less than the second.
|
|
126
|
+
*/
|
|
127
|
+
declare function lt<A extends number>(a: A, b: A): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Less Than or Equal: Compare if the first value is less than or equal to the second.
|
|
130
|
+
*/
|
|
131
|
+
declare function lte<A extends number>(a: A, b: A): boolean;
|
|
132
|
+
|
|
133
|
+
export { abs, add, ceil, div, eq, floor, gt, gte, inverse, lt, lte, max, min, mod, modSafe, mul, negate, pow, product, round, sqrt, sub, sum };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Inverse, Divide, Multiply, UnknownUnit } from '/home/rebec/dev/uom-types/src/base/index.ts';
|
|
2
|
+
|
|
3
|
+
type OperationResult<T extends number> = T extends UnknownUnit ? T : number;
|
|
4
|
+
/**
|
|
5
|
+
* Add two values together.
|
|
6
|
+
*/
|
|
7
|
+
declare function add<T extends number>(a: T, b: T): OperationResult<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Subtract one value from another.
|
|
10
|
+
*/
|
|
11
|
+
declare function sub<T extends number>(a: T, b: T): OperationResult<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Multiple two values together.
|
|
14
|
+
*/
|
|
15
|
+
declare function mul<T extends number>(a: T, b: T): OperationResult<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Divide one value by another.
|
|
18
|
+
*/
|
|
19
|
+
declare function div<T extends number>(a: T, b: T): OperationResult<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Modulo operator.
|
|
22
|
+
*
|
|
23
|
+
* @param a - Must be an integer.
|
|
24
|
+
* @param b - Must be an integer.
|
|
25
|
+
* @returns `a % b`
|
|
26
|
+
*/
|
|
27
|
+
declare function mod<T extends number>(a: T, b: T): OperationResult<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Perform mathematic modular arithmetic.
|
|
30
|
+
*
|
|
31
|
+
* @param a - Must be an integer.
|
|
32
|
+
* @param b - Must be a positive integer.
|
|
33
|
+
* @returns An integer between zero (inclusive) and `b` (exclusive).
|
|
34
|
+
*/
|
|
35
|
+
declare function modSafe<T extends number>(a: T, b: T): OperationResult<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Put a number to the power of -1.
|
|
38
|
+
*/
|
|
39
|
+
declare function pow<T extends number>(a: T, b: -1): OperationResult<Inverse<T>>;
|
|
40
|
+
/**
|
|
41
|
+
* Put a number to the power of 0.
|
|
42
|
+
*/
|
|
43
|
+
declare function pow<T extends number>(a: T, b: 0): 1;
|
|
44
|
+
/**
|
|
45
|
+
* Put a number to the power of 1/2.
|
|
46
|
+
*/
|
|
47
|
+
declare function pow<T extends number>(a: T, b: 0.5): OperationResult<Divide<T, 2>>;
|
|
48
|
+
/**
|
|
49
|
+
* Put a number to the power of 1.
|
|
50
|
+
*/
|
|
51
|
+
declare function pow<T extends number>(a: T, b: 1): T;
|
|
52
|
+
/**
|
|
53
|
+
* Put a number to the power of 2.
|
|
54
|
+
*/
|
|
55
|
+
declare function pow<T extends number>(a: T, b: 2): OperationResult<Multiply<T, T>>;
|
|
56
|
+
/**
|
|
57
|
+
* Put a number to the power of 3.
|
|
58
|
+
*/
|
|
59
|
+
declare function pow<T extends number>(a: T, b: 3): OperationResult<Multiply<T, Multiply<T, T>>>;
|
|
60
|
+
/**
|
|
61
|
+
* Put a number to the power of 4.
|
|
62
|
+
*/
|
|
63
|
+
declare function pow<T extends number>(a: T, b: 4): OperationResult<Multiply<T, Multiply<T, Multiply<T, T>>>>;
|
|
64
|
+
/**
|
|
65
|
+
* Put one number to the power of the other.
|
|
66
|
+
*/
|
|
67
|
+
declare function pow<T extends number>(a: T, b: T): number;
|
|
68
|
+
/**
|
|
69
|
+
* Take the square root of the given value.
|
|
70
|
+
*/
|
|
71
|
+
declare function sqrt<T extends number>(value: T): OperationResult<Divide<T, 2>>;
|
|
72
|
+
/**
|
|
73
|
+
* Inverse the given value.
|
|
74
|
+
*/
|
|
75
|
+
declare function inverse<T extends number>(value: T): OperationResult<Inverse<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Make the given value negative.
|
|
78
|
+
*/
|
|
79
|
+
declare function negate<T extends number>(value: T): OperationResult<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the absolute value of a number.
|
|
82
|
+
*/
|
|
83
|
+
declare function abs<T extends number>(value: T): OperationResult<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the greatest integer less than or equal to the given value.
|
|
86
|
+
*/
|
|
87
|
+
declare function floor<T extends number>(value: T): OperationResult<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the smallest integer greater than or equal the given value.
|
|
90
|
+
*/
|
|
91
|
+
declare function ceil<T extends number>(value: T): OperationResult<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Returns the given value rounded to the nearest integer.
|
|
94
|
+
*/
|
|
95
|
+
declare function round<T extends number>(value: T): OperationResult<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the larger value in the given collection.
|
|
98
|
+
*/
|
|
99
|
+
declare function max<T extends number>(values: Iterable<T>): OperationResult<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the smallest value in the given collection.
|
|
102
|
+
*/
|
|
103
|
+
declare function min<T extends number>(values: Iterable<T>): OperationResult<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Takes the sum of all the values in the given collection.
|
|
106
|
+
*/
|
|
107
|
+
declare function sum<T extends number>(values: ReadonlyArray<T>): OperationResult<T>;
|
|
108
|
+
/**
|
|
109
|
+
* Takes the product of all the values in the given collection.
|
|
110
|
+
*/
|
|
111
|
+
declare function product<T extends number>(values: ReadonlyArray<T>): OperationResult<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Equal: Compare if two values are equal.
|
|
114
|
+
*/
|
|
115
|
+
declare function eq<A extends number>(a: A, b: A): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Greater Than: Compare if the first value is greater than the second.
|
|
118
|
+
*/
|
|
119
|
+
declare function gt<A extends number>(a: A, b: A): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Greater Than or Equal: Compare if the first value is greater than or equal to the second.
|
|
122
|
+
*/
|
|
123
|
+
declare function gte<A extends number>(a: A, b: A): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Less Than: Compare if the first value is less than the second.
|
|
126
|
+
*/
|
|
127
|
+
declare function lt<A extends number>(a: A, b: A): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Less Than or Equal: Compare if the first value is less than or equal to the second.
|
|
130
|
+
*/
|
|
131
|
+
declare function lte<A extends number>(a: A, b: A): boolean;
|
|
132
|
+
|
|
133
|
+
export { abs, add, ceil, div, eq, floor, gt, gte, inverse, lt, lte, max, min, mod, modSafe, mul, negate, pow, product, round, sqrt, sub, sum };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add two values together.
|
|
3
|
+
*/
|
|
4
|
+
function add(a, b) {
|
|
5
|
+
return (a + b);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Subtract one value from another.
|
|
9
|
+
*/
|
|
10
|
+
function sub(a, b) {
|
|
11
|
+
return (a - b);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Multiple two values together.
|
|
15
|
+
*/
|
|
16
|
+
function mul(a, b) {
|
|
17
|
+
return (a * b);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Divide one value by another.
|
|
21
|
+
*/
|
|
22
|
+
function div(a, b) {
|
|
23
|
+
return (a / b);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Modulo operator.
|
|
27
|
+
*
|
|
28
|
+
* @param a - Must be an integer.
|
|
29
|
+
* @param b - Must be an integer.
|
|
30
|
+
* @returns `a % b`
|
|
31
|
+
*/
|
|
32
|
+
function mod(a, b) {
|
|
33
|
+
return (a % b);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Perform mathematic modular arithmetic.
|
|
37
|
+
*
|
|
38
|
+
* @param a - Must be an integer.
|
|
39
|
+
* @param b - Must be a positive integer.
|
|
40
|
+
* @returns An integer between zero (inclusive) and `b` (exclusive).
|
|
41
|
+
*/
|
|
42
|
+
function modSafe(a, b) {
|
|
43
|
+
return (((a % b) + b) % b);
|
|
44
|
+
}
|
|
45
|
+
function pow(a, b) {
|
|
46
|
+
return a ** b;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Take the square root of the given value.
|
|
50
|
+
*/
|
|
51
|
+
function sqrt(value) {
|
|
52
|
+
return pow(value, 0.5);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Inverse the given value.
|
|
56
|
+
*/
|
|
57
|
+
function inverse(value) {
|
|
58
|
+
return pow(value, -1);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Make the given value negative.
|
|
62
|
+
*/
|
|
63
|
+
function negate(value) {
|
|
64
|
+
return -value;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns the absolute value of a number.
|
|
68
|
+
*/
|
|
69
|
+
function abs(value) {
|
|
70
|
+
return Math.abs(value);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the greatest integer less than or equal to the given value.
|
|
74
|
+
*/
|
|
75
|
+
function floor(value) {
|
|
76
|
+
return Math.floor(value);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns the smallest integer greater than or equal the given value.
|
|
80
|
+
*/
|
|
81
|
+
function ceil(value) {
|
|
82
|
+
return Math.ceil(value);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns the given value rounded to the nearest integer.
|
|
86
|
+
*/
|
|
87
|
+
function round(value) {
|
|
88
|
+
return Math.round(value);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the larger value in the given collection.
|
|
92
|
+
*/
|
|
93
|
+
function max(values) {
|
|
94
|
+
return Math.max(...values);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns the smallest value in the given collection.
|
|
98
|
+
*/
|
|
99
|
+
function min(values) {
|
|
100
|
+
return Math.min(...values);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Takes the sum of all the values in the given collection.
|
|
104
|
+
*/
|
|
105
|
+
function sum(values) {
|
|
106
|
+
return values.reduce(add, 0);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Takes the product of all the values in the given collection.
|
|
110
|
+
*/
|
|
111
|
+
function product(values) {
|
|
112
|
+
return values.reduce(mul, 1);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Equal: Compare if two values are equal.
|
|
116
|
+
*/
|
|
117
|
+
function eq(a, b) {
|
|
118
|
+
return a === b;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Greater Than: Compare if the first value is greater than the second.
|
|
122
|
+
*/
|
|
123
|
+
function gt(a, b) {
|
|
124
|
+
return a > b;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Greater Than or Equal: Compare if the first value is greater than or equal to the second.
|
|
128
|
+
*/
|
|
129
|
+
function gte(a, b) {
|
|
130
|
+
return a >= b;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Less Than: Compare if the first value is less than the second.
|
|
134
|
+
*/
|
|
135
|
+
function lt(a, b) {
|
|
136
|
+
return a < b;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Less Than or Equal: Compare if the first value is less than or equal to the second.
|
|
140
|
+
*/
|
|
141
|
+
function lte(a, b) {
|
|
142
|
+
return a <= b;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export { abs, add, ceil, div, eq, floor, gt, gte, inverse, lt, lte, max, min, mod, modSafe, mul, negate, pow, product, round, sqrt, sub, sum };
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type BrandUnit<T extends Record<string, UnitValue>> = {
|
|
2
|
+
__exactKeys: keyof T;
|
|
3
|
+
__uom_types: {
|
|
4
|
+
[U in keyof T]: BrandUnitConfigValue<T[U]>;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
type BrandUnitConfigValue<T extends UnitValue> = ExcludeZeroExponents<T> & {
|
|
8
|
+
__exactKeys: keyof ExcludeZeroExponents<T>;
|
|
9
|
+
};
|
|
10
|
+
type GetUnitConfig<T> = T extends UnitFull<infer C> ? C : never;
|
|
11
|
+
type ExcludeZeroExponents<T extends UnitValue> = {
|
|
12
|
+
[K in keyof T as T[K] extends 0 ? never : K]: T[K];
|
|
13
|
+
};
|
|
14
|
+
type GetUnitValues<T extends Record<string, UnitValue>, U> = U extends keyof T ? T[U] : {
|
|
15
|
+
exponent: 0;
|
|
16
|
+
};
|
|
17
|
+
type KeysOfTwoObjects<A, B> = keyof A | keyof B;
|
|
18
|
+
type KeysOfKeyOfTwoObjects<A, B, K> = K extends keyof A ? K extends keyof B ? keyof A[K] | keyof B[K] : keyof A[K] : K extends keyof B ? keyof B[K] : never;
|
|
19
|
+
type Inverse<T extends number> = T extends Exponent ? NegativeExponent<T> : T extends UnknownUnit ? InverseUnit<T> : never;
|
|
20
|
+
type NegativeExponent<T extends Exponent> = T extends -6 ? 6 : T extends -5 ? 5 : T extends -4 ? 4 : T extends -3 ? 3 : T extends -2 ? 2 : T extends -1 ? 0 : T extends 0 ? 1 : T extends 1 ? -1 : T extends 2 ? -2 : T extends 3 ? -3 : T extends 4 ? -4 : T extends 5 ? -5 : T extends 6 ? -6 : never;
|
|
21
|
+
type InverseUnit<T extends UnknownUnit> = InverseUnitCore<T> extends Record<string, UnitValue> ? Unit<InverseUnitCore<T>> : never;
|
|
22
|
+
type InverseUnitCore<T extends UnknownUnit> = {
|
|
23
|
+
[U in keyof GetUnitConfig<T>]: {
|
|
24
|
+
[E in keyof GetUnitConfig<T>[U]]: NegativeExponent<GetUnitConfig<T>[U][E]>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type Multiply<A extends number, B extends number> = A extends Exponent ? B extends Exponent ? SumExponents<A, B> : never : A extends UnknownUnit ? B extends UnknownUnit ? MultiplyUnits<A, B> : never : never;
|
|
28
|
+
type MultiplyUnits<A extends UnknownUnit, B extends UnknownUnit> = MultiplyUnitsCore<A, B> extends Record<string, UnitValue> ? Unit<MultiplyUnitsCore<A, B>> : never;
|
|
29
|
+
type MultiplyUnitsCore<A extends UnknownUnit, B extends UnknownUnit> = {
|
|
30
|
+
[U in KeysOfTwoObjects<GetUnitConfig<A>, GetUnitConfig<B>>]: {
|
|
31
|
+
[E in KeysOfKeyOfTwoObjects<GetUnitConfig<A>, GetUnitConfig<B>, U>]: SumExponents<E extends keyof GetUnitValues<GetUnitConfig<A>, U> ? GetUnitValues<GetUnitConfig<A>, U>[E] extends Exponent ? GetUnitValues<GetUnitConfig<A>, U>[E] : 0 : 0, E extends keyof GetUnitValues<GetUnitConfig<B>, U> ? GetUnitValues<GetUnitConfig<B>, U>[E] extends Exponent ? GetUnitValues<GetUnitConfig<B>, U>[E] : 0 : 0>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
type Divide<A extends number, B extends number> = A extends Exponent ? B extends Exponent ? SubExponents<A, B> : never : A extends UnknownUnit ? B extends UnknownUnit ? DivideUnits<A, B> : never : never;
|
|
35
|
+
type DivideUnits<A extends UnknownUnit, B extends UnknownUnit> = MultiplyUnits<A, InverseUnit<B> extends UnknownUnit ? InverseUnit<B> : never>;
|
|
36
|
+
type SubExponents<A extends Exponent, B extends Exponent> = SumExponents<A, NegativeExponent<B>>;
|
|
37
|
+
type SumExponents<A extends Exponent, B extends Exponent> = A extends -6 ? B extends 0 ? A : B extends 1 ? -5 : B extends 2 ? -4 : B extends 3 ? -3 : B extends 4 ? -2 : B extends 5 ? -1 : B extends 6 ? 0 : never : A extends -5 ? B extends -1 ? -6 : B extends 0 ? A : B extends 1 ? -4 : B extends 2 ? -3 : B extends 3 ? -2 : B extends 4 ? -1 : B extends 5 ? 0 : B extends 6 ? 1 : never : A extends -4 ? B extends -2 ? -6 : B extends -1 ? -5 : B extends 0 ? A : B extends 1 ? -3 : B extends 2 ? -2 : B extends 3 ? -1 : B extends 4 ? 0 : B extends 5 ? 1 : B extends 6 ? 2 : never : A extends -3 ? B extends -3 ? -6 : B extends -2 ? -5 : B extends -1 ? -4 : B extends 0 ? A : B extends 1 ? -2 : B extends 2 ? -1 : B extends 3 ? 0 : B extends 4 ? 1 : B extends 5 ? 2 : B extends 6 ? 3 : never : A extends -2 ? B extends -4 ? -6 : B extends -3 ? -5 : B extends -2 ? -4 : B extends -1 ? -3 : B extends 0 ? A : B extends 1 ? -1 : B extends 2 ? 0 : B extends 3 ? 1 : B extends 4 ? 2 : B extends 5 ? 3 : B extends 6 ? 4 : never : A extends -1 ? B extends -5 ? -6 : B extends -4 ? -5 : B extends -3 ? -4 : B extends -2 ? -3 : B extends -1 ? -2 : B extends 0 ? A : B extends 1 ? 0 : B extends 2 ? 1 : B extends 3 ? 2 : B extends 4 ? 3 : B extends 5 ? 4 : B extends 6 ? 5 : never : A extends 0 ? B : A extends 1 ? B extends -6 ? -5 : B extends -5 ? -4 : B extends -4 ? -3 : B extends -3 ? -2 : B extends -2 ? -1 : B extends -1 ? 0 : B extends 0 ? A : B extends 1 ? 2 : B extends 2 ? 3 : B extends 3 ? 4 : B extends 4 ? 5 : B extends 5 ? 6 : never : A extends 2 ? B extends -6 ? -4 : B extends -5 ? -3 : B extends -4 ? -2 : B extends -3 ? -1 : B extends -2 ? 0 : B extends -1 ? 1 : B extends 0 ? A : B extends 1 ? 3 : B extends 2 ? 4 : B extends 3 ? 5 : B extends 4 ? 6 : never : A extends 3 ? B extends -6 ? -3 : B extends -5 ? -2 : B extends -4 ? -1 : B extends -3 ? 0 : B extends -2 ? 1 : B extends -1 ? 2 : B extends 0 ? A : B extends 1 ? 4 : B extends 2 ? 5 : B extends 3 ? 6 : never : A extends 4 ? B extends -6 ? -2 : B extends -5 ? -1 : B extends -4 ? 0 : B extends -3 ? 1 : B extends -2 ? 2 : B extends -1 ? 3 : B extends 0 ? A : B extends 1 ? 5 : B extends 2 ? 6 : never : A extends 5 ? B extends -6 ? -1 : B extends -5 ? 0 : B extends -4 ? 1 : B extends -3 ? 2 : B extends -2 ? 3 : B extends -1 ? 4 : B extends 0 ? A : B extends 1 ? 6 : never : A extends 6 ? B extends -6 ? 0 : B extends -5 ? 1 : B extends -4 ? 2 : B extends -3 ? 3 : B extends -2 ? 4 : B extends -1 ? 5 : B extends 0 ? A : never : never;
|
|
38
|
+
|
|
39
|
+
type Exponent = -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
40
|
+
type UnitFull<T extends Record<string, UnitValue>> = number & Readonly<BrandUnit<T>>;
|
|
41
|
+
type UnitValue = {
|
|
42
|
+
exponent: Exponent;
|
|
43
|
+
} & Record<string, Exponent>;
|
|
44
|
+
/**
|
|
45
|
+
* A unit of measurement.
|
|
46
|
+
*/
|
|
47
|
+
type Unit<T extends Record<string, Exponent | UnitValue>> = UnitFull<{
|
|
48
|
+
[K in keyof T]: T[K] extends Exponent ? {
|
|
49
|
+
exponent: T[K];
|
|
50
|
+
} : T[K] extends UnitValue ? T[K] : never;
|
|
51
|
+
}>;
|
|
52
|
+
type UnknownUnit = number & Readonly<{
|
|
53
|
+
__exactKeys: string;
|
|
54
|
+
__uom_types: Record<string, {}>;
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
export { Divide, Inverse, Multiply, Unit, UnknownUnit };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type BrandUnit<T extends Record<string, UnitValue>> = {
|
|
2
|
+
__exactKeys: keyof T;
|
|
3
|
+
__uom_types: {
|
|
4
|
+
[U in keyof T]: BrandUnitConfigValue<T[U]>;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
type BrandUnitConfigValue<T extends UnitValue> = ExcludeZeroExponents<T> & {
|
|
8
|
+
__exactKeys: keyof ExcludeZeroExponents<T>;
|
|
9
|
+
};
|
|
10
|
+
type GetUnitConfig<T> = T extends UnitFull<infer C> ? C : never;
|
|
11
|
+
type ExcludeZeroExponents<T extends UnitValue> = {
|
|
12
|
+
[K in keyof T as T[K] extends 0 ? never : K]: T[K];
|
|
13
|
+
};
|
|
14
|
+
type GetUnitValues<T extends Record<string, UnitValue>, U> = U extends keyof T ? T[U] : {
|
|
15
|
+
exponent: 0;
|
|
16
|
+
};
|
|
17
|
+
type KeysOfTwoObjects<A, B> = keyof A | keyof B;
|
|
18
|
+
type KeysOfKeyOfTwoObjects<A, B, K> = K extends keyof A ? K extends keyof B ? keyof A[K] | keyof B[K] : keyof A[K] : K extends keyof B ? keyof B[K] : never;
|
|
19
|
+
type Inverse<T extends number> = T extends Exponent ? NegativeExponent<T> : T extends UnknownUnit ? InverseUnit<T> : never;
|
|
20
|
+
type NegativeExponent<T extends Exponent> = T extends -6 ? 6 : T extends -5 ? 5 : T extends -4 ? 4 : T extends -3 ? 3 : T extends -2 ? 2 : T extends -1 ? 0 : T extends 0 ? 1 : T extends 1 ? -1 : T extends 2 ? -2 : T extends 3 ? -3 : T extends 4 ? -4 : T extends 5 ? -5 : T extends 6 ? -6 : never;
|
|
21
|
+
type InverseUnit<T extends UnknownUnit> = InverseUnitCore<T> extends Record<string, UnitValue> ? Unit<InverseUnitCore<T>> : never;
|
|
22
|
+
type InverseUnitCore<T extends UnknownUnit> = {
|
|
23
|
+
[U in keyof GetUnitConfig<T>]: {
|
|
24
|
+
[E in keyof GetUnitConfig<T>[U]]: NegativeExponent<GetUnitConfig<T>[U][E]>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type Multiply<A extends number, B extends number> = A extends Exponent ? B extends Exponent ? SumExponents<A, B> : never : A extends UnknownUnit ? B extends UnknownUnit ? MultiplyUnits<A, B> : never : never;
|
|
28
|
+
type MultiplyUnits<A extends UnknownUnit, B extends UnknownUnit> = MultiplyUnitsCore<A, B> extends Record<string, UnitValue> ? Unit<MultiplyUnitsCore<A, B>> : never;
|
|
29
|
+
type MultiplyUnitsCore<A extends UnknownUnit, B extends UnknownUnit> = {
|
|
30
|
+
[U in KeysOfTwoObjects<GetUnitConfig<A>, GetUnitConfig<B>>]: {
|
|
31
|
+
[E in KeysOfKeyOfTwoObjects<GetUnitConfig<A>, GetUnitConfig<B>, U>]: SumExponents<E extends keyof GetUnitValues<GetUnitConfig<A>, U> ? GetUnitValues<GetUnitConfig<A>, U>[E] extends Exponent ? GetUnitValues<GetUnitConfig<A>, U>[E] : 0 : 0, E extends keyof GetUnitValues<GetUnitConfig<B>, U> ? GetUnitValues<GetUnitConfig<B>, U>[E] extends Exponent ? GetUnitValues<GetUnitConfig<B>, U>[E] : 0 : 0>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
type Divide<A extends number, B extends number> = A extends Exponent ? B extends Exponent ? SubExponents<A, B> : never : A extends UnknownUnit ? B extends UnknownUnit ? DivideUnits<A, B> : never : never;
|
|
35
|
+
type DivideUnits<A extends UnknownUnit, B extends UnknownUnit> = MultiplyUnits<A, InverseUnit<B> extends UnknownUnit ? InverseUnit<B> : never>;
|
|
36
|
+
type SubExponents<A extends Exponent, B extends Exponent> = SumExponents<A, NegativeExponent<B>>;
|
|
37
|
+
type SumExponents<A extends Exponent, B extends Exponent> = A extends -6 ? B extends 0 ? A : B extends 1 ? -5 : B extends 2 ? -4 : B extends 3 ? -3 : B extends 4 ? -2 : B extends 5 ? -1 : B extends 6 ? 0 : never : A extends -5 ? B extends -1 ? -6 : B extends 0 ? A : B extends 1 ? -4 : B extends 2 ? -3 : B extends 3 ? -2 : B extends 4 ? -1 : B extends 5 ? 0 : B extends 6 ? 1 : never : A extends -4 ? B extends -2 ? -6 : B extends -1 ? -5 : B extends 0 ? A : B extends 1 ? -3 : B extends 2 ? -2 : B extends 3 ? -1 : B extends 4 ? 0 : B extends 5 ? 1 : B extends 6 ? 2 : never : A extends -3 ? B extends -3 ? -6 : B extends -2 ? -5 : B extends -1 ? -4 : B extends 0 ? A : B extends 1 ? -2 : B extends 2 ? -1 : B extends 3 ? 0 : B extends 4 ? 1 : B extends 5 ? 2 : B extends 6 ? 3 : never : A extends -2 ? B extends -4 ? -6 : B extends -3 ? -5 : B extends -2 ? -4 : B extends -1 ? -3 : B extends 0 ? A : B extends 1 ? -1 : B extends 2 ? 0 : B extends 3 ? 1 : B extends 4 ? 2 : B extends 5 ? 3 : B extends 6 ? 4 : never : A extends -1 ? B extends -5 ? -6 : B extends -4 ? -5 : B extends -3 ? -4 : B extends -2 ? -3 : B extends -1 ? -2 : B extends 0 ? A : B extends 1 ? 0 : B extends 2 ? 1 : B extends 3 ? 2 : B extends 4 ? 3 : B extends 5 ? 4 : B extends 6 ? 5 : never : A extends 0 ? B : A extends 1 ? B extends -6 ? -5 : B extends -5 ? -4 : B extends -4 ? -3 : B extends -3 ? -2 : B extends -2 ? -1 : B extends -1 ? 0 : B extends 0 ? A : B extends 1 ? 2 : B extends 2 ? 3 : B extends 3 ? 4 : B extends 4 ? 5 : B extends 5 ? 6 : never : A extends 2 ? B extends -6 ? -4 : B extends -5 ? -3 : B extends -4 ? -2 : B extends -3 ? -1 : B extends -2 ? 0 : B extends -1 ? 1 : B extends 0 ? A : B extends 1 ? 3 : B extends 2 ? 4 : B extends 3 ? 5 : B extends 4 ? 6 : never : A extends 3 ? B extends -6 ? -3 : B extends -5 ? -2 : B extends -4 ? -1 : B extends -3 ? 0 : B extends -2 ? 1 : B extends -1 ? 2 : B extends 0 ? A : B extends 1 ? 4 : B extends 2 ? 5 : B extends 3 ? 6 : never : A extends 4 ? B extends -6 ? -2 : B extends -5 ? -1 : B extends -4 ? 0 : B extends -3 ? 1 : B extends -2 ? 2 : B extends -1 ? 3 : B extends 0 ? A : B extends 1 ? 5 : B extends 2 ? 6 : never : A extends 5 ? B extends -6 ? -1 : B extends -5 ? 0 : B extends -4 ? 1 : B extends -3 ? 2 : B extends -2 ? 3 : B extends -1 ? 4 : B extends 0 ? A : B extends 1 ? 6 : never : A extends 6 ? B extends -6 ? 0 : B extends -5 ? 1 : B extends -4 ? 2 : B extends -3 ? 3 : B extends -2 ? 4 : B extends -1 ? 5 : B extends 0 ? A : never : never;
|
|
38
|
+
|
|
39
|
+
type Exponent = -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
40
|
+
type UnitFull<T extends Record<string, UnitValue>> = number & Readonly<BrandUnit<T>>;
|
|
41
|
+
type UnitValue = {
|
|
42
|
+
exponent: Exponent;
|
|
43
|
+
} & Record<string, Exponent>;
|
|
44
|
+
/**
|
|
45
|
+
* A unit of measurement.
|
|
46
|
+
*/
|
|
47
|
+
type Unit<T extends Record<string, Exponent | UnitValue>> = UnitFull<{
|
|
48
|
+
[K in keyof T]: T[K] extends Exponent ? {
|
|
49
|
+
exponent: T[K];
|
|
50
|
+
} : T[K] extends UnitValue ? T[K] : never;
|
|
51
|
+
}>;
|
|
52
|
+
type UnknownUnit = number & Readonly<{
|
|
53
|
+
__exactKeys: string;
|
|
54
|
+
__uom_types: Record<string, {}>;
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
export { Divide, Inverse, Multiply, Unit, UnknownUnit };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uom-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typesafe units with no runtime overhead.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"uom",
|
|
7
|
+
"units",
|
|
8
|
+
"measure",
|
|
9
|
+
"types"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/RebeccaStevens/uom-types#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/RebeccaStevens/uom-types/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/RebeccaStevens/uom-types"
|
|
18
|
+
},
|
|
19
|
+
"license": "BSD-3-Clause",
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Rebecca Stevens",
|
|
22
|
+
"email": "rebecca.stevens@outlook.co.nz"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": {
|
|
28
|
+
"import": "./dist/index.d.mts",
|
|
29
|
+
"require": "./dist/index.d.cts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./functions": {
|
|
33
|
+
"types": {
|
|
34
|
+
"import": "./dist/functions.d.mts",
|
|
35
|
+
"require": "./dist/functions.d.cts"
|
|
36
|
+
},
|
|
37
|
+
"import": "./dist/functions.mjs",
|
|
38
|
+
"require": "./dist/functions.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./functions/higher-order": {
|
|
41
|
+
"types": {
|
|
42
|
+
"import": "./dist/functions-ho.d.mts",
|
|
43
|
+
"require": "./dist/functions-ho.d.cts"
|
|
44
|
+
},
|
|
45
|
+
"import": "./dist/functions-ho.mjs",
|
|
46
|
+
"require": "./dist/functions-ho.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./si-units": {
|
|
49
|
+
"types": {
|
|
50
|
+
"import": "./dist/si-units.d.mts",
|
|
51
|
+
"require": "./dist/si-units.d.cts"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"./si-units/converters": {
|
|
55
|
+
"types": {
|
|
56
|
+
"import": "./dist/si-units-converters.d.mts",
|
|
57
|
+
"require": "./dist/si-units-converters.d.cts"
|
|
58
|
+
},
|
|
59
|
+
"import": "./dist/si-units-converters.mjs",
|
|
60
|
+
"require": "./dist/si-units-converters.cjs"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"files": [
|
|
64
|
+
"dist/",
|
|
65
|
+
"package.json",
|
|
66
|
+
"LICENSE",
|
|
67
|
+
"README.md"
|
|
68
|
+
],
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "pnpm run build:node",
|
|
71
|
+
"build:node": "rimraf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
72
|
+
"cz": "git-cz",
|
|
73
|
+
"lint": "pnpm run lint:js && pnpm run lint:md && pnpm run lint:prettier && pnpm run lint:knip && pnpm run lint:spelling",
|
|
74
|
+
"lint:js": "eslint .",
|
|
75
|
+
"lint:js-fix": "eslint . --fix",
|
|
76
|
+
"lint:knip": "pnpm run lint:knip:development && pnpm run lint:knip:production",
|
|
77
|
+
"lint:knip:development": "knip --exclude exports,nsExports,types,nsTypes",
|
|
78
|
+
"lint:knip:production": "knip --production --strict --exclude exports,nsExports,types,nsTypes",
|
|
79
|
+
"lint:md": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
|
|
80
|
+
"lint:prettier": "prettier \"**/*\" --ignore-unknown --list-different",
|
|
81
|
+
"lint:prettier-fix": "prettier \"**/*\" --ignore-unknown --write",
|
|
82
|
+
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
|
83
|
+
"prepare": "husky install",
|
|
84
|
+
"release": "pnpm run release:pre && pnpm run release:semantic",
|
|
85
|
+
"release:pre": "node --no-warnings=ExperimentalWarning --loader=ts-paths-esm-loader/transpile-only --experimental-specifier-resolution=node ./scripts/pre-release.ts",
|
|
86
|
+
"release:semantic": "semantic-release",
|
|
87
|
+
"test": "pnpm run test:js",
|
|
88
|
+
"test:js": "c8 ava",
|
|
89
|
+
"type-check": "tsc --noEmit"
|
|
90
|
+
},
|
|
91
|
+
"devDependencies": {
|
|
92
|
+
"@commitlint/cli": "17.6.6",
|
|
93
|
+
"@commitlint/config-conventional": "17.6.6",
|
|
94
|
+
"@cspell/dict-cryptocurrencies": "3.0.1",
|
|
95
|
+
"@rebeccastevens/eslint-config": "1.7.8",
|
|
96
|
+
"@rollup/plugin-node-resolve": "15.1.0",
|
|
97
|
+
"@rollup/plugin-typescript": "11.1.2",
|
|
98
|
+
"@semantic-release/changelog": "6.0.3",
|
|
99
|
+
"@semantic-release/commit-analyzer": "10.0.1",
|
|
100
|
+
"@semantic-release/git": "10.0.1",
|
|
101
|
+
"@semantic-release/github": "9.0.3",
|
|
102
|
+
"@semantic-release/npm": "10.0.4",
|
|
103
|
+
"@semantic-release/release-notes-generator": "11.0.4",
|
|
104
|
+
"@types/node": "18.15.11",
|
|
105
|
+
"@types/rollup-plugin-auto-external": "2.0.2",
|
|
106
|
+
"@typescript-eslint/eslint-plugin": "5.61.0",
|
|
107
|
+
"@typescript-eslint/parser": "5.61.0",
|
|
108
|
+
"ava": "5.3.1",
|
|
109
|
+
"c8": "8.0.0",
|
|
110
|
+
"commitizen": "4.3.0",
|
|
111
|
+
"cspell": "6.31.1",
|
|
112
|
+
"cz-conventional-changelog": "3.3.0",
|
|
113
|
+
"eslint": "8.44.0",
|
|
114
|
+
"eslint-config-prettier": "8.8.0",
|
|
115
|
+
"eslint-import-resolver-typescript": "3.5.5",
|
|
116
|
+
"eslint-plugin-ava": "14.0.0",
|
|
117
|
+
"eslint-plugin-eslint-comments": "3.2.0",
|
|
118
|
+
"eslint-plugin-functional": "5.0.8",
|
|
119
|
+
"eslint-plugin-import": "2.27.5",
|
|
120
|
+
"eslint-plugin-jsdoc": "46.4.3",
|
|
121
|
+
"eslint-plugin-markdown": "3.0.0",
|
|
122
|
+
"eslint-plugin-n": "16.0.1",
|
|
123
|
+
"eslint-plugin-optimize-regex": "1.2.1",
|
|
124
|
+
"eslint-plugin-prettier": "5.0.0-alpha.1",
|
|
125
|
+
"eslint-plugin-promise": "6.1.1",
|
|
126
|
+
"eslint-plugin-sonarjs": "0.19.0",
|
|
127
|
+
"eslint-plugin-unicorn": "47.0.0",
|
|
128
|
+
"husky": "8.0.3",
|
|
129
|
+
"knip": "2.14.3",
|
|
130
|
+
"lint-staged": "13.2.3",
|
|
131
|
+
"markdownlint-cli": "0.35.0",
|
|
132
|
+
"prettier": "3.0.0",
|
|
133
|
+
"prettier-plugin-packagejson": "2.4.4",
|
|
134
|
+
"rimraf": "5.0.1",
|
|
135
|
+
"rollup": "3.26.1",
|
|
136
|
+
"rollup-plugin-auto-external": "2.0.0",
|
|
137
|
+
"rollup-plugin-dts": "5.3.0",
|
|
138
|
+
"semantic-release": "21.0.7",
|
|
139
|
+
"ts-node": "10.9.1",
|
|
140
|
+
"ts-paths-esm-loader": "1.4.3",
|
|
141
|
+
"tsconfig-paths": "4.2.0",
|
|
142
|
+
"typescript": "5.1.6"
|
|
143
|
+
},
|
|
144
|
+
"packageManager": "pnpm@8.6.6",
|
|
145
|
+
"engines": {
|
|
146
|
+
"node": ">=16.0.0"
|
|
147
|
+
}
|
|
148
|
+
}
|