@tempots/std 0.10.7 → 0.12.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/README.md +2 -0
- package/array.cjs +1 -1
- package/array.d.ts +357 -35
- package/array.js +148 -152
- package/async-result.cjs +1 -1
- package/async-result.d.ts +161 -23
- package/async-result.js +119 -13
- package/bigint.cjs +1 -1
- package/bigint.d.ts +155 -18
- package/bigint.js +37 -37
- package/boolean.cjs +1 -1
- package/boolean.d.ts +39 -7
- package/boolean.js +10 -10
- package/domain.d.ts +149 -5
- package/equal.d.ts +26 -0
- package/function.cjs +1 -1
- package/function.d.ts +24 -1
- package/function.js +15 -19
- package/index.cjs +1 -1
- package/index.d.ts +13 -0
- package/index.js +185 -1
- package/json.d.ts +20 -1
- package/number.d.ts +324 -55
- package/object.cjs +1 -1
- package/object.d.ts +53 -5
- package/object.js +15 -15
- package/package.json +26 -19
- package/regexp.cjs +1 -1
- package/regexp.d.ts +5 -4
- package/regexp.js +8 -8
- package/result-Czm7RKNP.js +230 -0
- package/result-DzdZiQoR.cjs +1 -0
- package/result.cjs +1 -1
- package/result.d.ts +132 -8
- package/result.js +3 -54
- package/string.cjs +4 -3
- package/string.d.ts +220 -10
- package/string.js +166 -160
- package/validation.cjs +1 -1
- package/validation.d.ts +72 -4
- package/validation.js +2 -23
- package/maybe.cjs +0 -1
- package/maybe.d.ts +0 -9
- package/maybe.js +0 -9
package/async-result.js
CHANGED
|
@@ -1,40 +1,146 @@
|
|
|
1
1
|
const u = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Creates a loading state.
|
|
4
|
+
* @param previousValue - The previous value.
|
|
5
|
+
* @returns A loading state.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
notAsked: { type: "NotAsked" },
|
|
9
|
+
/**
|
|
10
|
+
* Creates a loading state.
|
|
11
|
+
* @param previousValue - The previous value.
|
|
12
|
+
* @returns A loading state.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
loading(e = void 0) {
|
|
16
|
+
return { type: "Loading", previousValue: e };
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Creates a successful state.
|
|
20
|
+
* @param value - The value.
|
|
21
|
+
* @returns A successful state.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
4
24
|
success(e) {
|
|
5
|
-
return { type: "
|
|
25
|
+
return { type: "AsyncSuccess", value: e };
|
|
6
26
|
},
|
|
27
|
+
/**
|
|
28
|
+
* Creates a failure state.
|
|
29
|
+
* @param error - The error.
|
|
30
|
+
* @returns A failure state.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
7
33
|
failure(e) {
|
|
8
|
-
return { type: "
|
|
34
|
+
return { type: "AsyncFailure", error: e };
|
|
9
35
|
},
|
|
36
|
+
/**
|
|
37
|
+
* Checks if the result is a success.
|
|
38
|
+
* @param r - The result.
|
|
39
|
+
* @returns `true` if the result is a success; otherwise, `false`.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
10
42
|
isSuccess(e) {
|
|
11
|
-
return e.type === "
|
|
43
|
+
return e.type === "AsyncSuccess";
|
|
12
44
|
},
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the result is a failure.
|
|
47
|
+
* @param r - The result.
|
|
48
|
+
* @returns `true` if the result is a failure; otherwise, `false`.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
13
51
|
isFailure(e) {
|
|
14
|
-
return e.type === "
|
|
52
|
+
return e.type === "AsyncFailure";
|
|
15
53
|
},
|
|
16
|
-
|
|
17
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Checks if the result is a not-asked.
|
|
56
|
+
* @param r - The result.
|
|
57
|
+
* @returns `true` if the result is not-asked; otherwise, `false`.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
isNotAsked(e) {
|
|
61
|
+
return e.type === "NotAsked";
|
|
18
62
|
},
|
|
63
|
+
/**
|
|
64
|
+
* Checks if the result is a loading.
|
|
65
|
+
* @param r - The result.
|
|
66
|
+
* @returns `true` if the result is loading; otherwise, `false`.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
19
69
|
isLoading(e) {
|
|
20
|
-
return e.type === "
|
|
70
|
+
return e.type === "Loading";
|
|
21
71
|
},
|
|
72
|
+
/**
|
|
73
|
+
* Gets the value if the result is a success; otherwise, returns the alternative value.
|
|
74
|
+
* @param r - The result.
|
|
75
|
+
* @param alt - The alternative value.
|
|
76
|
+
* @returns The value if the result is a success; otherwise, the alternative value.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
22
79
|
getOrElse(e, s) {
|
|
23
80
|
return u.isSuccess(e) ? e.value : s;
|
|
24
81
|
},
|
|
82
|
+
/**
|
|
83
|
+
* Gets the value if the result is a success; otherwise, returns the value from the alternative function.
|
|
84
|
+
* @param r - The result.
|
|
85
|
+
* @param altf - The alternative function.
|
|
86
|
+
* @returns The value if the result is a success; otherwise, the value from the alternative
|
|
87
|
+
* @public
|
|
88
|
+
* function.
|
|
89
|
+
*/
|
|
25
90
|
getOrElseLazy(e, s) {
|
|
26
91
|
return u.isSuccess(e) ? e.value : s();
|
|
27
92
|
},
|
|
93
|
+
/**
|
|
94
|
+
* Gets the value if the result is a success; otherwise, returns `null`.
|
|
95
|
+
* @param r - The result.
|
|
96
|
+
* @returns The value if the result is a success; otherwise, `null`.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
28
99
|
getOrNull(e) {
|
|
29
100
|
return u.isSuccess(e) ? e.value : null;
|
|
30
101
|
},
|
|
102
|
+
/**
|
|
103
|
+
* Gets the value if the result is a success; otherwise, returns `undefined`.
|
|
104
|
+
* @param r - The result.
|
|
105
|
+
* @returns The value if the result is a success; otherwise, `undefined`.
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
31
108
|
getOrUndefined(e) {
|
|
32
109
|
return u.isSuccess(e) ? e.value : void 0;
|
|
33
110
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
113
|
+
* @param success - The function to call if the result is a success.
|
|
114
|
+
* @param failure - The function to call if the result is a failure.
|
|
115
|
+
* @param loading - The function to call if the result is loading.
|
|
116
|
+
* @param notAsked - The function to call if the result is not-asked.
|
|
117
|
+
* @returns The result of calling the appropriate function based on the state of the result.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
match: (e, {
|
|
121
|
+
success: s,
|
|
122
|
+
failure: t,
|
|
123
|
+
loading: r,
|
|
124
|
+
notAsked: i = r
|
|
125
|
+
}) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ? t(e.error) : u.isNotAsked(e) ? i() : r(e.previousValue),
|
|
126
|
+
/**
|
|
127
|
+
* When the result is a success, it applies the function to the value.
|
|
128
|
+
*
|
|
129
|
+
* @param r - The result.
|
|
130
|
+
* @param apply - The function to apply.
|
|
131
|
+
* @returns The result that was passed in.
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
whenSuccess: (e, s) => (u.isSuccess(e) && s(e.value), e),
|
|
135
|
+
/**
|
|
136
|
+
* When the result is a failure, it applies the function to the error.
|
|
137
|
+
*
|
|
138
|
+
* @param r - The result.
|
|
139
|
+
* @param apply - The function to apply.
|
|
140
|
+
* @returns The result that was passed in.
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
whenFailure: (e, s) => (u.isFailure(e) && s(e.error), e)
|
|
38
144
|
};
|
|
39
145
|
export {
|
|
40
146
|
u as AsyncResult
|
package/bigint.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(n,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(n,i){return i<0n&&(n=-n,i=-i),n<=0n?n/i:(n-1n)/i+1n}function b(n,i){return i<0n&&(n=-n,i=-i),n>=0n?n/i:(n+1n)/i-1n}function f(n,i){return n<i?-1:n>i?1:0}function r(n){return n<0n?-n:n}function s(n,i){return n<i?n:i}function c(n,i){return n>i?n:i}function l(n,i){if(i<0n)throw new Error("negative exponent");let e=1n;for(;i>0n;)(i&1n)!==0n&&(e*=n),i>>=1n,n*=n;return e}function u(n,i){for(n=r(n),i=r(i);i>0n;){const e=i;i=n%i,n=e}return n}function v(n,i){return r(n*i)/u(n,i)}function t(n){if(n<2n)return!1;if(n===2n||n===3n)return!0;if(n%2n===0n||n%3n===0n)return!1;let i=5n;for(;i*i<=n;){if(n%i===0n||n%(i+2n)===0n)return!1;i+=6n}return!0}function I(n){if(n<2n)return 2n;if(n===2n)return 3n;for(n%2n===0n?n++:n+=2n;!t(n);)n+=2n;return n}function P(n){if(n<=2n)throw new Error("no previous prime");if(n===3n)return 2n;for(n%2n===0n?n--:n-=2n;!t(n);)n-=2n;return n}function a(n){return n%2n===0n}function m(n){return n%2n!==0n}function w(n){return n===0n}function d(n){return n===1n}function h(n){return n<0n}function p(n){return n>0n}exports.biAbs=r;exports.biCeilDiv=o;exports.biCompare=f;exports.biFloorDiv=b;exports.biGcd=u;exports.biIsEven=a;exports.biIsNegative=h;exports.biIsOdd=m;exports.biIsOne=d;exports.biIsPositive=p;exports.biIsPrime=t;exports.biIsZero=w;exports.biLcm=v;exports.biMax=c;exports.biMin=s;exports.biNextPrime=I;exports.biPow=l;exports.biPrevPrime=P;
|
package/bigint.d.ts
CHANGED
|
@@ -1,18 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export declare function
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the ceiling division of two BigInt numbers.
|
|
3
|
+
*
|
|
4
|
+
* @param x - The dividend.
|
|
5
|
+
* @param y - The divisor.
|
|
6
|
+
* @returns The result of dividing `x` by `y`, rounded up to the nearest whole number.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function biCeilDiv(x: bigint, y: bigint): bigint;
|
|
10
|
+
/**
|
|
11
|
+
* Divides two BigInt numbers and returns the largest integer less than or equal to the quotient.
|
|
12
|
+
*
|
|
13
|
+
* @param x - The dividend.
|
|
14
|
+
* @param y - The divisor.
|
|
15
|
+
* @returns The largest integer less than or equal to the quotient of `x` divided by `y`.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare function biFloorDiv(x: bigint, y: bigint): bigint;
|
|
19
|
+
/**
|
|
20
|
+
* Compares two BigInt values and returns a number indicating their relative order.
|
|
21
|
+
* @param x - The first BigInt value to compare.
|
|
22
|
+
* @param y - The second BigInt value to compare.
|
|
23
|
+
* @returns A negative number if `x` is less than `y`, a positive number if `x` is greater than `y`,
|
|
24
|
+
* @public
|
|
25
|
+
* or zero if `x` is equal to `y`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function biCompare(x: bigint, y: bigint): number;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the absolute value of a bigint.
|
|
30
|
+
*
|
|
31
|
+
* @param x - The bigint to compute the absolute value of.
|
|
32
|
+
* @returns The absolute value of `x`.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare function biAbs(x: bigint): bigint;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the minimum of two BigInt values.
|
|
38
|
+
*
|
|
39
|
+
* @param x - The first BigInt value.
|
|
40
|
+
* @param y - The second BigInt value.
|
|
41
|
+
* @returns The smaller of the two BigInt values.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function biMin(x: bigint, y: bigint): bigint;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the maximum of two BigInt values.
|
|
47
|
+
*
|
|
48
|
+
* @param x - The first BigInt value.
|
|
49
|
+
* @param y - The second BigInt value.
|
|
50
|
+
* @returns The maximum of the two BigInt values.
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export declare function biMax(x: bigint, y: bigint): bigint;
|
|
54
|
+
/**
|
|
55
|
+
* Calculates the power of a bigint number.
|
|
56
|
+
*
|
|
57
|
+
* @param x - The base number.
|
|
58
|
+
* @param y - The exponent.
|
|
59
|
+
* @returns The result of raising `x` to the power of `y`.
|
|
60
|
+
* @public
|
|
61
|
+
* @throws Error If the exponent `y` is negative.
|
|
62
|
+
*/
|
|
63
|
+
export declare function biPow(x: bigint, y: bigint): bigint;
|
|
64
|
+
/**
|
|
65
|
+
* Calculates the greatest common divisor (GCD) of two BigInt numbers.
|
|
66
|
+
*
|
|
67
|
+
* @param x - The first BigInt number.
|
|
68
|
+
* @param y - The second BigInt number.
|
|
69
|
+
* @returns The GCD of `x` and `y`.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare function biGcd(x: bigint, y: bigint): bigint;
|
|
73
|
+
/**
|
|
74
|
+
* Calculates the least common multiple (LCM) of two BigInt numbers.
|
|
75
|
+
*
|
|
76
|
+
* @param x - The first BigInt number.
|
|
77
|
+
* @param y - The second BigInt number.
|
|
78
|
+
* @returns The least common multiple of `x` and `y`.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare function biLcm(x: bigint, y: bigint): bigint;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if a given number is prime.
|
|
84
|
+
*
|
|
85
|
+
* @param x - The number to check for primality.
|
|
86
|
+
* @returns `true` if the number is prime, `false` otherwise.
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
export declare function biIsPrime(x: bigint): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Finds the next prime number greater than the given number.
|
|
92
|
+
*
|
|
93
|
+
* @param x - The starting number.
|
|
94
|
+
* @returns The next prime number greater than `x`.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare function biNextPrime(x: bigint): bigint;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the previous prime number less than the given number.
|
|
100
|
+
* Throws an error if there is no previous prime.
|
|
101
|
+
*
|
|
102
|
+
* @param x - The number to find the previous prime for.
|
|
103
|
+
* @returns The previous prime number less than `x`.
|
|
104
|
+
* @public
|
|
105
|
+
* @throws Error if there is no previous prime.
|
|
106
|
+
*/
|
|
107
|
+
export declare function biPrevPrime(x: bigint): bigint;
|
|
108
|
+
/**
|
|
109
|
+
* Checks if a given bigint is even.
|
|
110
|
+
*
|
|
111
|
+
* @param x - The bigint to check.
|
|
112
|
+
* @returns `true` if the bigint is even, `false` otherwise.
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export declare function biIsEven(x: bigint): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Checks if a given bigint is odd.
|
|
118
|
+
*
|
|
119
|
+
* @param x - The bigint to check.
|
|
120
|
+
* @returns `true` if the bigint is odd, `false` otherwise.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export declare function biIsOdd(x: bigint): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Checks if a given bigint is zero.
|
|
126
|
+
*
|
|
127
|
+
* @param x - The bigint to check.
|
|
128
|
+
* @returns `true` if the bigint is zero, `false` otherwise.
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export declare function biIsZero(x: bigint): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Checks if a given bigint is equal to 1n.
|
|
134
|
+
*
|
|
135
|
+
* @param x - The bigint to check.
|
|
136
|
+
* @returns `true` if the bigint is equal to 1n, `false` otherwise.
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare function biIsOne(x: bigint): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Checks if a given bigint is negative.
|
|
142
|
+
*
|
|
143
|
+
* @param x - The bigint to check.
|
|
144
|
+
* @returns `true` if the bigint is negative, `false` otherwise.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare function biIsNegative(x: bigint): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Checks if a bigint is positive.
|
|
150
|
+
*
|
|
151
|
+
* @param x - The bigint to check.
|
|
152
|
+
* @returns `true` if the bigint is positive, `false` otherwise.
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
export declare function biIsPositive(x: bigint): boolean;
|
package/bigint.js
CHANGED
|
@@ -7,31 +7,31 @@ function o(n, r) {
|
|
|
7
7
|
function c(n, r) {
|
|
8
8
|
return n < r ? -1 : n > r ? 1 : 0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function e(n) {
|
|
11
11
|
return n < 0n ? -n : n;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function b(n, r) {
|
|
14
14
|
return n < r ? n : r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function s(n, r) {
|
|
17
17
|
return n > r ? n : r;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function l(n, r) {
|
|
20
20
|
if (r < 0n) throw new Error("negative exponent");
|
|
21
|
-
let
|
|
21
|
+
let i = 1n;
|
|
22
22
|
for (; r > 0n; )
|
|
23
|
-
(r & 1n) !== 0n && (
|
|
24
|
-
return
|
|
23
|
+
(r & 1n) !== 0n && (i *= n), r >>= 1n, n *= n;
|
|
24
|
+
return i;
|
|
25
25
|
}
|
|
26
26
|
function u(n, r) {
|
|
27
|
-
for (n =
|
|
28
|
-
const
|
|
29
|
-
r = n % r, n =
|
|
27
|
+
for (n = e(n), r = e(r); r > 0n; ) {
|
|
28
|
+
const i = r;
|
|
29
|
+
r = n % r, n = i;
|
|
30
30
|
}
|
|
31
31
|
return n;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function w(n, r) {
|
|
34
|
+
return e(n * r) / u(n, r);
|
|
35
35
|
}
|
|
36
36
|
function t(n) {
|
|
37
37
|
if (n < 2n) return !1;
|
|
@@ -44,13 +44,13 @@ function t(n) {
|
|
|
44
44
|
}
|
|
45
45
|
return !0;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function v(n) {
|
|
48
48
|
if (n < 2n) return 2n;
|
|
49
49
|
if (n === 2n) return 3n;
|
|
50
50
|
for (n % 2n === 0n ? n++ : n += 2n; !t(n); ) n += 2n;
|
|
51
51
|
return n;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function a(n) {
|
|
54
54
|
if (n <= 2n) throw new Error("no previous prime");
|
|
55
55
|
if (n === 3n) return 2n;
|
|
56
56
|
for (n % 2n === 0n ? n-- : n -= 2n; !t(n); ) n -= 2n;
|
|
@@ -59,38 +59,38 @@ function v(n) {
|
|
|
59
59
|
function h(n) {
|
|
60
60
|
return n % 2n === 0n;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function I(n) {
|
|
63
63
|
return n % 2n !== 0n;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function m(n) {
|
|
66
66
|
return n === 0n;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function P(n) {
|
|
69
69
|
return n === 1n;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function p(n) {
|
|
72
72
|
return n < 0n;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function d(n) {
|
|
75
75
|
return n > 0n;
|
|
76
76
|
}
|
|
77
77
|
export {
|
|
78
|
-
|
|
79
|
-
f as
|
|
80
|
-
c as
|
|
81
|
-
o as
|
|
82
|
-
u as
|
|
83
|
-
h as
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
t as
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
78
|
+
e as biAbs,
|
|
79
|
+
f as biCeilDiv,
|
|
80
|
+
c as biCompare,
|
|
81
|
+
o as biFloorDiv,
|
|
82
|
+
u as biGcd,
|
|
83
|
+
h as biIsEven,
|
|
84
|
+
p as biIsNegative,
|
|
85
|
+
I as biIsOdd,
|
|
86
|
+
P as biIsOne,
|
|
87
|
+
d as biIsPositive,
|
|
88
|
+
t as biIsPrime,
|
|
89
|
+
m as biIsZero,
|
|
90
|
+
w as biLcm,
|
|
91
|
+
s as biMax,
|
|
92
|
+
b as biMin,
|
|
93
|
+
v as biNextPrime,
|
|
94
|
+
l as biPow,
|
|
95
|
+
a as biPrevPrime
|
|
96
96
|
};
|
package/boolean.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(e,o){return e===o?0:e?-1:1}function n(e){return e?1:0}function r(e){if(e==null)return!1;switch(e.toLowerCase()){case"true":case"false":case"0":case"1":case"on":case"off":return!0;default:return!1}}function t(e){switch(e.toLowerCase()){case"true":case"1":case"on":return!0;case"false":case"0":case"off":return!1;default:throw new Error(`unable to parse '${e}'`)}}function s(e,o){return e!==o}exports.booleanToInt=n;exports.canParseBoolean=r;exports.compareBooleans=a;exports.parseBoolean=t;exports.xorBoolean=s;
|
package/boolean.d.ts
CHANGED
|
@@ -3,21 +3,53 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Returns a comparison value (`Int`) from two boolean values.
|
|
6
|
+
*
|
|
7
|
+
* @param a - The first boolean value.
|
|
8
|
+
* @param b - The second boolean value.
|
|
9
|
+
* @returns A comparison value.
|
|
10
|
+
* @public
|
|
6
11
|
*/
|
|
7
|
-
export declare function
|
|
12
|
+
export declare function compareBooleans(a: boolean, b: boolean): number;
|
|
8
13
|
/**
|
|
9
14
|
* Converts a boolean to an integer value (`true` => `1`, `false` => `0`).
|
|
15
|
+
*
|
|
16
|
+
* @param v - The boolean value.
|
|
17
|
+
* @returns The integer value.
|
|
18
|
+
* @public
|
|
10
19
|
*/
|
|
11
|
-
export declare function
|
|
20
|
+
export declare function booleanToInt(v: boolean): number;
|
|
12
21
|
/**
|
|
13
|
-
* Returns `true` if the passed value
|
|
22
|
+
* Returns `true` if the passed value can be parsed as a boolean. The following values are considered parsable:
|
|
23
|
+
*
|
|
24
|
+
* - `'true'` / `'false'`
|
|
25
|
+
* - `'0'` / `'1'`
|
|
26
|
+
* - `'on'` / `'off'`
|
|
27
|
+
*
|
|
28
|
+
* The comparison is case insensitive.
|
|
29
|
+
*
|
|
30
|
+
* @param v - The value to check.
|
|
31
|
+
* @returns `true` if the value can be parsed; otherwise, `false`.
|
|
32
|
+
* @public
|
|
14
33
|
*/
|
|
15
|
-
export declare function
|
|
34
|
+
export declare function canParseBoolean(v: string): boolean;
|
|
16
35
|
/**
|
|
17
|
-
* Returns `true`/`false` if the passed value
|
|
36
|
+
* Returns `true`/`false` if the passed value can be parsed. The following values are considered parsable:
|
|
37
|
+
*
|
|
38
|
+
* - `'true'` / `'false'`
|
|
39
|
+
* - `'0'` / `'1'`
|
|
40
|
+
* - `'on'` / `'off'`
|
|
41
|
+
*
|
|
42
|
+
* @param v - The value to parse.
|
|
43
|
+
* @returns The parsed boolean value.
|
|
44
|
+
* @public
|
|
18
45
|
*/
|
|
19
|
-
export declare function
|
|
46
|
+
export declare function parseBoolean(v: string): boolean;
|
|
20
47
|
/**
|
|
21
48
|
* Returns `true` when arguments are different.
|
|
49
|
+
*
|
|
50
|
+
* @param a - The first boolean value.
|
|
51
|
+
* @param b - The second boolean value.
|
|
52
|
+
* @returns The result of the XOR operation.
|
|
53
|
+
* @public
|
|
22
54
|
*/
|
|
23
|
-
export declare function
|
|
55
|
+
export declare function xorBoolean(a: boolean, b: boolean): boolean;
|
package/boolean.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a(e, r) {
|
|
2
2
|
return e === r ? 0 : e ? -1 : 1;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function n(e) {
|
|
5
5
|
return e ? 1 : 0;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function o(e) {
|
|
8
8
|
if (e == null) return !1;
|
|
9
9
|
switch (e.toLowerCase()) {
|
|
10
10
|
case "true":
|
|
@@ -18,7 +18,7 @@ function n(e) {
|
|
|
18
18
|
return !1;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function t(e) {
|
|
22
22
|
switch (e.toLowerCase()) {
|
|
23
23
|
case "true":
|
|
24
24
|
case "1":
|
|
@@ -32,13 +32,13 @@ function s(e) {
|
|
|
32
32
|
throw new Error(`unable to parse '${e}'`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function s(e, r) {
|
|
36
36
|
return e !== r;
|
|
37
37
|
}
|
|
38
38
|
export {
|
|
39
|
-
n as
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
n as booleanToInt,
|
|
40
|
+
o as canParseBoolean,
|
|
41
|
+
a as compareBooleans,
|
|
42
|
+
t as parseBoolean,
|
|
43
|
+
s as xorBoolean
|
|
44
44
|
};
|