@tempots/std 0.13.0 → 0.15.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/array.cjs +1 -1
- package/array.d.ts +35 -35
- package/array.js +109 -168
- package/async-result.cjs +1 -1
- package/async-result.d.ts +38 -15
- package/async-result.js +40 -5
- package/bigint.cjs +1 -1
- package/bigint.d.ts +20 -20
- package/bigint.js +37 -78
- package/boolean.cjs +1 -1
- package/boolean.d.ts +5 -5
- package/boolean.js +10 -19
- package/equal.cjs +1 -1
- package/equal.d.ts +3 -3
- package/equal.js +31 -37
- package/error.cjs +1 -0
- package/error.d.ts +24 -0
- package/error.js +26 -0
- package/function.cjs +1 -1
- package/function.d.ts +3 -3
- package/function.js +4 -10
- package/index.cjs +1 -1
- package/index.d.ts +1 -0
- package/index.js +120 -118
- package/number.cjs +1 -1
- package/number.d.ts +25 -46
- package/number.js +29 -86
- package/object.cjs +1 -1
- package/object.d.ts +6 -6
- package/object.js +12 -27
- package/package.json +15 -1
- package/promise.cjs +1 -0
- package/promise.d.ts +11 -0
- package/promise.js +9 -0
- package/regexp.cjs +1 -1
- package/regexp.d.ts +1 -1
- package/regexp.js +8 -8
- package/{result-Czm7RKNP.js → result-CGd0jCdl.js} +54 -19
- package/result-CdwVhaAc.cjs +1 -0
- package/result.cjs +1 -1
- package/result.d.ts +31 -8
- package/result.js +1 -1
- package/string.cjs +4 -4
- package/string.d.ts +85 -89
- package/string.js +193 -379
- package/validation.cjs +1 -1
- package/validation.d.ts +7 -7
- package/validation.js +1 -1
- package/result-DzdZiQoR.cjs +0 -1
package/async-result.d.ts
CHANGED
|
@@ -4,35 +4,35 @@ import { Maybe } from './domain';
|
|
|
4
4
|
* Represents the state when a result has not been requested yet.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
type: 'NotAsked';
|
|
9
|
-
}
|
|
7
|
+
export type NotAsked = {
|
|
8
|
+
readonly type: 'NotAsked';
|
|
9
|
+
};
|
|
10
10
|
/**
|
|
11
11
|
* Represents a loading state in an asynchronous result.
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
15
|
-
type: 'Loading';
|
|
16
|
-
previousValue?: V;
|
|
17
|
-
}
|
|
14
|
+
export type Loading<V> = {
|
|
15
|
+
readonly type: 'Loading';
|
|
16
|
+
readonly previousValue?: V;
|
|
17
|
+
};
|
|
18
18
|
/**
|
|
19
19
|
* Represents a successful result.
|
|
20
20
|
* @typeParam V - The type of the value.
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
24
|
-
type: 'AsyncSuccess';
|
|
25
|
-
value: V;
|
|
26
|
-
}
|
|
23
|
+
export type AsyncSuccess<V> = {
|
|
24
|
+
readonly type: 'AsyncSuccess';
|
|
25
|
+
readonly value: V;
|
|
26
|
+
};
|
|
27
27
|
/**
|
|
28
28
|
* Represents a failure result.
|
|
29
29
|
* @typeParam E - - The type of the error.
|
|
30
30
|
* @public
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
33
|
-
type: 'AsyncFailure';
|
|
34
|
-
error: E;
|
|
35
|
-
}
|
|
32
|
+
export type AsyncFailure<E> = {
|
|
33
|
+
readonly type: 'AsyncFailure';
|
|
34
|
+
readonly error: E;
|
|
35
|
+
};
|
|
36
36
|
/**
|
|
37
37
|
* Represents the result of an asynchronous operation that can be in one of the following states:
|
|
38
38
|
* - `NotAsked`: The operation has not been requested yet.
|
|
@@ -139,6 +139,12 @@ export declare const AsyncResult: {
|
|
|
139
139
|
* @public
|
|
140
140
|
*/
|
|
141
141
|
getOrUndefined<V, E>(r: AsyncResult<V, E>): Maybe<V>;
|
|
142
|
+
/**
|
|
143
|
+
* Gets the value of a `AsyncResult` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
|
|
144
|
+
* @param r - The `AsyncResult` to get the value from.
|
|
145
|
+
* @returns The value of the `AsyncResult` if it is a `Success`.
|
|
146
|
+
*/
|
|
147
|
+
getUnsafe: <V, E>(r: AsyncResult<V, E>) => V;
|
|
142
148
|
/**
|
|
143
149
|
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
144
150
|
* @param success - The function to call if the result is a success.
|
|
@@ -172,4 +178,21 @@ export declare const AsyncResult: {
|
|
|
172
178
|
* @public
|
|
173
179
|
*/
|
|
174
180
|
whenFailure: <V, E>(r: AsyncResult<V, E>, apply: (e: E) => void) => AsyncResult<V, E>;
|
|
181
|
+
/**
|
|
182
|
+
* Compares two results for equality.
|
|
183
|
+
* @param r1 - The first result.
|
|
184
|
+
* @param r2 - The second result.
|
|
185
|
+
* @param options - The options to use for comparison. By default, uses strict equality.
|
|
186
|
+
* @returns `true` if the results are equal, `false` otherwise.
|
|
187
|
+
*/
|
|
188
|
+
equals: <V, E>(r1: AsyncResult<V, E>, r2: AsyncResult<V, E>, options?: {
|
|
189
|
+
valueEquals: (v1: V, v2: V) => boolean;
|
|
190
|
+
errorEquals: (e1: E, e2: E) => boolean;
|
|
191
|
+
}) => boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Combines multiple results into a single result.
|
|
194
|
+
* @param results - The results to combine.
|
|
195
|
+
* @returns A single result that is a success if all the input results are successes, otherwise a failure.
|
|
196
|
+
*/
|
|
197
|
+
all: <V, E>(results: AsyncResult<V, E>[]) => AsyncResult<V[], E>;
|
|
175
198
|
};
|
package/async-result.js
CHANGED
|
@@ -108,6 +108,16 @@ const u = {
|
|
|
108
108
|
getOrUndefined(e) {
|
|
109
109
|
return u.isSuccess(e) ? e.value : void 0;
|
|
110
110
|
},
|
|
111
|
+
/**
|
|
112
|
+
* Gets the value of a `AsyncResult` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
|
|
113
|
+
* @param r - The `AsyncResult` to get the value from.
|
|
114
|
+
* @returns The value of the `AsyncResult` if it is a `Success`.
|
|
115
|
+
*/
|
|
116
|
+
getUnsafe: (e) => {
|
|
117
|
+
if (u.isSuccess(e))
|
|
118
|
+
return e.value;
|
|
119
|
+
throw u.isFailure(e) ? e.error : new Error("Cannot get value from a not-asked or loading result");
|
|
120
|
+
},
|
|
111
121
|
/**
|
|
112
122
|
* Based on the state of the result, it picks the appropriate function to call and returns the result.
|
|
113
123
|
* @param success - The function to call if the result is a success.
|
|
@@ -119,10 +129,10 @@ const u = {
|
|
|
119
129
|
*/
|
|
120
130
|
match: (e, {
|
|
121
131
|
success: s,
|
|
122
|
-
failure:
|
|
123
|
-
loading:
|
|
124
|
-
notAsked:
|
|
125
|
-
}) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ?
|
|
132
|
+
failure: r,
|
|
133
|
+
loading: t,
|
|
134
|
+
notAsked: l = t
|
|
135
|
+
}) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ? r(e.error) : u.isNotAsked(e) ? l() : t(e.previousValue),
|
|
126
136
|
/**
|
|
127
137
|
* When the result is a success, it applies the function to the value.
|
|
128
138
|
*
|
|
@@ -140,7 +150,32 @@ const u = {
|
|
|
140
150
|
* @returns The result that was passed in.
|
|
141
151
|
* @public
|
|
142
152
|
*/
|
|
143
|
-
whenFailure: (e, s) => (u.isFailure(e) && s(e.error), e)
|
|
153
|
+
whenFailure: (e, s) => (u.isFailure(e) && s(e.error), e),
|
|
154
|
+
/**
|
|
155
|
+
* Compares two results for equality.
|
|
156
|
+
* @param r1 - The first result.
|
|
157
|
+
* @param r2 - The second result.
|
|
158
|
+
* @param options - The options to use for comparison. By default, uses strict equality.
|
|
159
|
+
* @returns `true` if the results are equal, `false` otherwise.
|
|
160
|
+
*/
|
|
161
|
+
equals: (e, s, r = {
|
|
162
|
+
valueEquals: (t, l) => t === l,
|
|
163
|
+
errorEquals: (t, l) => t === l
|
|
164
|
+
}) => e.type === "AsyncSuccess" && s.type === "AsyncSuccess" ? r.valueEquals(e.value, s.value) : e.type === "AsyncFailure" && s.type === "AsyncFailure" ? r.errorEquals(e.error, s.error) : e.type === "Loading" && s.type === "Loading" ? r.valueEquals(e.previousValue, s.previousValue) : e.type === "NotAsked" && s.type === "NotAsked",
|
|
165
|
+
/**
|
|
166
|
+
* Combines multiple results into a single result.
|
|
167
|
+
* @param results - The results to combine.
|
|
168
|
+
* @returns A single result that is a success if all the input results are successes, otherwise a failure.
|
|
169
|
+
*/
|
|
170
|
+
all: (e) => {
|
|
171
|
+
const s = [];
|
|
172
|
+
for (const r of e)
|
|
173
|
+
if (u.isSuccess(r))
|
|
174
|
+
s.push(r.value);
|
|
175
|
+
else
|
|
176
|
+
return r;
|
|
177
|
+
return u.success(s);
|
|
178
|
+
}
|
|
144
179
|
};
|
|
145
180
|
export {
|
|
146
181
|
u as AsyncResult
|
package/bigint.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./error.cjs"),b=(n,i)=>(i<0n&&(n=-n,i=-i),n<=0n?n/i:(n-1n)/i+1n),c=(n,i)=>(i<0n&&(n=-n,i=-i),n>=0n?n/i:(n+1n)/i-1n),u=(n,i)=>n<i?-1:n>i?1:0,r=n=>n<0n?-n:n,f=(n,i)=>n<i?n:i,l=(n,i)=>n>i?n:i,m=(n,i)=>{if(i<0n)throw new o.ArgumentError("negative exponent for parameter y of biPow");let e=1n;for(;i>0n;)(i&1n)!==0n&&(e*=n),i>>=1n,n*=n;return e},s=(n,i)=>{for(n=r(n),i=r(i);i>0n;){const e=i;i=n%i,n=e}return n},v=(n,i)=>r(n*i)/s(n,i),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},P=n=>{if(n<2n)return 2n;if(n===2n)return 3n;for(n%2n===0n?n++:n+=2n;!t(n);)n+=2n;return n},a=n=>{if(n<=2n)throw new o.ArgumentError(`no previous prime ${n} for biPrevPrime`);if(n===3n)return 2n;for(n%2n===0n?n--:n-=2n;!t(n);)n-=2n;return n},I=n=>n%2n===0n,w=n=>n%2n!==0n,d=n=>n===0n,g=n=>n===1n,h=n=>n<0n,p=n=>n>0n;exports.biAbs=r;exports.biCeilDiv=b;exports.biCompare=u;exports.biFloorDiv=c;exports.biGcd=s;exports.biIsEven=I;exports.biIsNegative=h;exports.biIsOdd=w;exports.biIsOne=g;exports.biIsPositive=p;exports.biIsPrime=t;exports.biIsZero=d;exports.biLcm=v;exports.biMax=l;exports.biMin=f;exports.biNextPrime=P;exports.biPow=m;exports.biPrevPrime=a;
|
package/bigint.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @returns The result of dividing `x` by `y`, rounded up to the nearest whole number.
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare const biCeilDiv: (x: bigint, y: bigint) => bigint;
|
|
10
10
|
/**
|
|
11
11
|
* Divides two BigInt numbers and returns the largest integer less than or equal to the quotient.
|
|
12
12
|
*
|
|
@@ -15,7 +15,7 @@ export declare function biCeilDiv(x: bigint, y: bigint): bigint;
|
|
|
15
15
|
* @returns The largest integer less than or equal to the quotient of `x` divided by `y`.
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
export declare
|
|
18
|
+
export declare const biFloorDiv: (x: bigint, y: bigint) => bigint;
|
|
19
19
|
/**
|
|
20
20
|
* Compares two BigInt values and returns a number indicating their relative order.
|
|
21
21
|
* @param x - The first BigInt value to compare.
|
|
@@ -24,7 +24,7 @@ export declare function biFloorDiv(x: bigint, y: bigint): bigint;
|
|
|
24
24
|
* @public
|
|
25
25
|
* or zero if `x` is equal to `y`.
|
|
26
26
|
*/
|
|
27
|
-
export declare
|
|
27
|
+
export declare const biCompare: (x: bigint, y: bigint) => number;
|
|
28
28
|
/**
|
|
29
29
|
* Returns the absolute value of a bigint.
|
|
30
30
|
*
|
|
@@ -32,7 +32,7 @@ export declare function biCompare(x: bigint, y: bigint): number;
|
|
|
32
32
|
* @returns The absolute value of `x`.
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
|
-
export declare
|
|
35
|
+
export declare const biAbs: (x: bigint) => bigint;
|
|
36
36
|
/**
|
|
37
37
|
* Returns the minimum of two BigInt values.
|
|
38
38
|
*
|
|
@@ -41,7 +41,7 @@ export declare function biAbs(x: bigint): bigint;
|
|
|
41
41
|
* @returns The smaller of the two BigInt values.
|
|
42
42
|
* @public
|
|
43
43
|
*/
|
|
44
|
-
export declare
|
|
44
|
+
export declare const biMin: (x: bigint, y: bigint) => bigint;
|
|
45
45
|
/**
|
|
46
46
|
* Returns the maximum of two BigInt values.
|
|
47
47
|
*
|
|
@@ -50,7 +50,7 @@ export declare function biMin(x: bigint, y: bigint): bigint;
|
|
|
50
50
|
* @returns The maximum of the two BigInt values.
|
|
51
51
|
* @public
|
|
52
52
|
*/
|
|
53
|
-
export declare
|
|
53
|
+
export declare const biMax: (x: bigint, y: bigint) => bigint;
|
|
54
54
|
/**
|
|
55
55
|
* Calculates the power of a bigint number.
|
|
56
56
|
*
|
|
@@ -58,9 +58,9 @@ export declare function biMax(x: bigint, y: bigint): bigint;
|
|
|
58
58
|
* @param y - The exponent.
|
|
59
59
|
* @returns The result of raising `x` to the power of `y`.
|
|
60
60
|
* @public
|
|
61
|
-
* @throws
|
|
61
|
+
* @throws Throws `ArgumentError` if the exponent `y` is negative.
|
|
62
62
|
*/
|
|
63
|
-
export declare
|
|
63
|
+
export declare const biPow: (x: bigint, y: bigint) => bigint;
|
|
64
64
|
/**
|
|
65
65
|
* Calculates the greatest common divisor (GCD) of two BigInt numbers.
|
|
66
66
|
*
|
|
@@ -69,7 +69,7 @@ export declare function biPow(x: bigint, y: bigint): bigint;
|
|
|
69
69
|
* @returns The GCD of `x` and `y`.
|
|
70
70
|
* @public
|
|
71
71
|
*/
|
|
72
|
-
export declare
|
|
72
|
+
export declare const biGcd: (x: bigint, y: bigint) => bigint;
|
|
73
73
|
/**
|
|
74
74
|
* Calculates the least common multiple (LCM) of two BigInt numbers.
|
|
75
75
|
*
|
|
@@ -78,7 +78,7 @@ export declare function biGcd(x: bigint, y: bigint): bigint;
|
|
|
78
78
|
* @returns The least common multiple of `x` and `y`.
|
|
79
79
|
* @public
|
|
80
80
|
*/
|
|
81
|
-
export declare
|
|
81
|
+
export declare const biLcm: (x: bigint, y: bigint) => bigint;
|
|
82
82
|
/**
|
|
83
83
|
* Checks if a given number is prime.
|
|
84
84
|
*
|
|
@@ -86,7 +86,7 @@ export declare function biLcm(x: bigint, y: bigint): bigint;
|
|
|
86
86
|
* @returns `true` if the number is prime, `false` otherwise.
|
|
87
87
|
* @public
|
|
88
88
|
*/
|
|
89
|
-
export declare
|
|
89
|
+
export declare const biIsPrime: (x: bigint) => boolean;
|
|
90
90
|
/**
|
|
91
91
|
* Finds the next prime number greater than the given number.
|
|
92
92
|
*
|
|
@@ -94,7 +94,7 @@ export declare function biIsPrime(x: bigint): boolean;
|
|
|
94
94
|
* @returns The next prime number greater than `x`.
|
|
95
95
|
* @public
|
|
96
96
|
*/
|
|
97
|
-
export declare
|
|
97
|
+
export declare const biNextPrime: (x: bigint) => bigint;
|
|
98
98
|
/**
|
|
99
99
|
* Returns the previous prime number less than the given number.
|
|
100
100
|
* Throws an error if there is no previous prime.
|
|
@@ -102,9 +102,9 @@ export declare function biNextPrime(x: bigint): bigint;
|
|
|
102
102
|
* @param x - The number to find the previous prime for.
|
|
103
103
|
* @returns The previous prime number less than `x`.
|
|
104
104
|
* @public
|
|
105
|
-
* @throws
|
|
105
|
+
* @throws Throws `ArgumentError` if there is no previous prime.
|
|
106
106
|
*/
|
|
107
|
-
export declare
|
|
107
|
+
export declare const biPrevPrime: (x: bigint) => bigint;
|
|
108
108
|
/**
|
|
109
109
|
* Checks if a given bigint is even.
|
|
110
110
|
*
|
|
@@ -112,7 +112,7 @@ export declare function biPrevPrime(x: bigint): bigint;
|
|
|
112
112
|
* @returns `true` if the bigint is even, `false` otherwise.
|
|
113
113
|
* @public
|
|
114
114
|
*/
|
|
115
|
-
export declare
|
|
115
|
+
export declare const biIsEven: (x: bigint) => boolean;
|
|
116
116
|
/**
|
|
117
117
|
* Checks if a given bigint is odd.
|
|
118
118
|
*
|
|
@@ -120,7 +120,7 @@ export declare function biIsEven(x: bigint): boolean;
|
|
|
120
120
|
* @returns `true` if the bigint is odd, `false` otherwise.
|
|
121
121
|
* @public
|
|
122
122
|
*/
|
|
123
|
-
export declare
|
|
123
|
+
export declare const biIsOdd: (x: bigint) => boolean;
|
|
124
124
|
/**
|
|
125
125
|
* Checks if a given bigint is zero.
|
|
126
126
|
*
|
|
@@ -128,7 +128,7 @@ export declare function biIsOdd(x: bigint): boolean;
|
|
|
128
128
|
* @returns `true` if the bigint is zero, `false` otherwise.
|
|
129
129
|
* @public
|
|
130
130
|
*/
|
|
131
|
-
export declare
|
|
131
|
+
export declare const biIsZero: (x: bigint) => boolean;
|
|
132
132
|
/**
|
|
133
133
|
* Checks if a given bigint is equal to 1n.
|
|
134
134
|
*
|
|
@@ -136,7 +136,7 @@ export declare function biIsZero(x: bigint): boolean;
|
|
|
136
136
|
* @returns `true` if the bigint is equal to 1n, `false` otherwise.
|
|
137
137
|
* @public
|
|
138
138
|
*/
|
|
139
|
-
export declare
|
|
139
|
+
export declare const biIsOne: (x: bigint) => boolean;
|
|
140
140
|
/**
|
|
141
141
|
* Checks if a given bigint is negative.
|
|
142
142
|
*
|
|
@@ -144,7 +144,7 @@ export declare function biIsOne(x: bigint): boolean;
|
|
|
144
144
|
* @returns `true` if the bigint is negative, `false` otherwise.
|
|
145
145
|
* @public
|
|
146
146
|
*/
|
|
147
|
-
export declare
|
|
147
|
+
export declare const biIsNegative: (x: bigint) => boolean;
|
|
148
148
|
/**
|
|
149
149
|
* Checks if a bigint is positive.
|
|
150
150
|
*
|
|
@@ -152,4 +152,4 @@ export declare function biIsNegative(x: bigint): boolean;
|
|
|
152
152
|
* @returns `true` if the bigint is positive, `false` otherwise.
|
|
153
153
|
* @public
|
|
154
154
|
*/
|
|
155
|
-
export declare
|
|
155
|
+
export declare const biIsPositive: (x: bigint) => boolean;
|
package/bigint.js
CHANGED
|
@@ -1,96 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return r < 0n && (n = -n, r = -r), n >= 0n ? n / r : (n + 1n) / r - 1n;
|
|
6
|
-
}
|
|
7
|
-
function c(n, r) {
|
|
8
|
-
return n < r ? -1 : n > r ? 1 : 0;
|
|
9
|
-
}
|
|
10
|
-
function e(n) {
|
|
11
|
-
return n < 0n ? -n : n;
|
|
12
|
-
}
|
|
13
|
-
function b(n, r) {
|
|
14
|
-
return n < r ? n : r;
|
|
15
|
-
}
|
|
16
|
-
function s(n, r) {
|
|
17
|
-
return n > r ? n : r;
|
|
18
|
-
}
|
|
19
|
-
function l(n, r) {
|
|
20
|
-
if (r < 0n) throw new Error("negative exponent");
|
|
1
|
+
import { ArgumentError as t } from "./error.js";
|
|
2
|
+
const c = (n, e) => (e < 0n && (n = -n, e = -e), n <= 0n ? n / e : (n - 1n) / e + 1n), f = (n, e) => (e < 0n && (n = -n, e = -e), n >= 0n ? n / e : (n + 1n) / e - 1n), u = (n, e) => n < e ? -1 : n > e ? 1 : 0, r = (n) => n < 0n ? -n : n, l = (n, e) => n < e ? n : e, m = (n, e) => n > e ? n : e, w = (n, e) => {
|
|
3
|
+
if (e < 0n)
|
|
4
|
+
throw new t("negative exponent for parameter y of biPow");
|
|
21
5
|
let i = 1n;
|
|
22
|
-
for (;
|
|
23
|
-
(
|
|
6
|
+
for (; e > 0n; )
|
|
7
|
+
(e & 1n) !== 0n && (i *= n), e >>= 1n, n *= n;
|
|
24
8
|
return i;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
r = n % r, n = i;
|
|
9
|
+
}, s = (n, e) => {
|
|
10
|
+
for (n = r(n), e = r(e); e > 0n; ) {
|
|
11
|
+
const i = e;
|
|
12
|
+
e = n % e, n = i;
|
|
30
13
|
}
|
|
31
14
|
return n;
|
|
32
|
-
}
|
|
33
|
-
function w(n, r) {
|
|
34
|
-
return e(n * r) / u(n, r);
|
|
35
|
-
}
|
|
36
|
-
function t(n) {
|
|
15
|
+
}, a = (n, e) => r(n * e) / s(n, e), o = (n) => {
|
|
37
16
|
if (n < 2n) return !1;
|
|
38
17
|
if (n === 2n || n === 3n) return !0;
|
|
39
18
|
if (n % 2n === 0n || n % 3n === 0n) return !1;
|
|
40
|
-
let
|
|
41
|
-
for (;
|
|
42
|
-
if (n %
|
|
43
|
-
|
|
19
|
+
let e = 5n;
|
|
20
|
+
for (; e * e <= n; ) {
|
|
21
|
+
if (n % e === 0n || n % (e + 2n) === 0n) return !1;
|
|
22
|
+
e += 6n;
|
|
44
23
|
}
|
|
45
24
|
return !0;
|
|
46
|
-
}
|
|
47
|
-
function v(n) {
|
|
25
|
+
}, v = (n) => {
|
|
48
26
|
if (n < 2n) return 2n;
|
|
49
27
|
if (n === 2n) return 3n;
|
|
50
|
-
for (n % 2n === 0n ? n++ : n += 2n; !
|
|
28
|
+
for (n % 2n === 0n ? n++ : n += 2n; !o(n); ) n += 2n;
|
|
51
29
|
return n;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (n <= 2n) throw new Error("no previous prime");
|
|
30
|
+
}, P = (n) => {
|
|
31
|
+
if (n <= 2n) throw new t(`no previous prime ${n} for biPrevPrime`);
|
|
55
32
|
if (n === 3n) return 2n;
|
|
56
|
-
for (n % 2n === 0n ? n-- : n -= 2n; !
|
|
33
|
+
for (n % 2n === 0n ? n-- : n -= 2n; !o(n); ) n -= 2n;
|
|
57
34
|
return n;
|
|
58
|
-
}
|
|
59
|
-
function h(n) {
|
|
60
|
-
return n % 2n === 0n;
|
|
61
|
-
}
|
|
62
|
-
function I(n) {
|
|
63
|
-
return n % 2n !== 0n;
|
|
64
|
-
}
|
|
65
|
-
function m(n) {
|
|
66
|
-
return n === 0n;
|
|
67
|
-
}
|
|
68
|
-
function P(n) {
|
|
69
|
-
return n === 1n;
|
|
70
|
-
}
|
|
71
|
-
function p(n) {
|
|
72
|
-
return n < 0n;
|
|
73
|
-
}
|
|
74
|
-
function d(n) {
|
|
75
|
-
return n > 0n;
|
|
76
|
-
}
|
|
35
|
+
}, h = (n) => n % 2n === 0n, p = (n) => n % 2n !== 0n, I = (n) => n === 0n, d = (n) => n === 1n, g = (n) => n < 0n, A = (n) => n > 0n;
|
|
77
36
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
37
|
+
r as biAbs,
|
|
38
|
+
c as biCeilDiv,
|
|
39
|
+
u as biCompare,
|
|
40
|
+
f as biFloorDiv,
|
|
41
|
+
s as biGcd,
|
|
83
42
|
h as biIsEven,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
43
|
+
g as biIsNegative,
|
|
44
|
+
p as biIsOdd,
|
|
45
|
+
d as biIsOne,
|
|
46
|
+
A as biIsPositive,
|
|
47
|
+
o as biIsPrime,
|
|
48
|
+
I as biIsZero,
|
|
49
|
+
a as biLcm,
|
|
50
|
+
m as biMax,
|
|
51
|
+
l as biMin,
|
|
93
52
|
v as biNextPrime,
|
|
94
|
-
|
|
95
|
-
|
|
53
|
+
w as biPow,
|
|
54
|
+
P as biPrevPrime
|
|
96
55
|
};
|
package/boolean.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./error.cjs"),r=(e,o)=>e===o?0:e?-1:1,s=e=>e?1:0,n=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}},t=e=>{switch(e.toLowerCase()){case"true":case"1":case"on":return!0;case"false":case"0":case"off":return!1;default:throw new a.ParsingError(`unable to parse '${e}' to boolean`)}},c=(e,o)=>e!==o;exports.booleanToInt=s;exports.canParseBoolean=n;exports.compareBooleans=r;exports.parseBoolean=t;exports.xorBoolean=c;
|
package/boolean.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @returns A comparison value.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
export declare
|
|
12
|
+
export declare const compareBooleans: (a: boolean, b: boolean) => number;
|
|
13
13
|
/**
|
|
14
14
|
* Converts a boolean to an integer value (`true` => `1`, `false` => `0`).
|
|
15
15
|
*
|
|
@@ -17,7 +17,7 @@ export declare function compareBooleans(a: boolean, b: boolean): number;
|
|
|
17
17
|
* @returns The integer value.
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
|
-
export declare
|
|
20
|
+
export declare const booleanToInt: (v: boolean) => number;
|
|
21
21
|
/**
|
|
22
22
|
* Returns `true` if the passed value can be parsed as a boolean. The following values are considered parsable:
|
|
23
23
|
*
|
|
@@ -31,7 +31,7 @@ export declare function booleanToInt(v: boolean): number;
|
|
|
31
31
|
* @returns `true` if the value can be parsed; otherwise, `false`.
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
|
-
export declare
|
|
34
|
+
export declare const canParseBoolean: (v: string) => boolean;
|
|
35
35
|
/**
|
|
36
36
|
* Returns `true`/`false` if the passed value can be parsed. The following values are considered parsable:
|
|
37
37
|
*
|
|
@@ -43,7 +43,7 @@ export declare function canParseBoolean(v: string): boolean;
|
|
|
43
43
|
* @returns The parsed boolean value.
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
|
-
export declare
|
|
46
|
+
export declare const parseBoolean: (v: string) => boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Returns `true` when arguments are different.
|
|
49
49
|
*
|
|
@@ -52,4 +52,4 @@ export declare function parseBoolean(v: string): boolean;
|
|
|
52
52
|
* @returns The result of the XOR operation.
|
|
53
53
|
* @public
|
|
54
54
|
*/
|
|
55
|
-
export declare
|
|
55
|
+
export declare const xorBoolean: (a: boolean, b: boolean) => boolean;
|
package/boolean.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
function n(e) {
|
|
5
|
-
return e ? 1 : 0;
|
|
6
|
-
}
|
|
7
|
-
function o(e) {
|
|
1
|
+
import { ParsingError as a } from "./error.js";
|
|
2
|
+
const r = (e, o) => e === o ? 0 : e ? -1 : 1, t = (e) => e ? 1 : 0, n = (e) => {
|
|
8
3
|
if (e == null) return !1;
|
|
9
4
|
switch (e.toLowerCase()) {
|
|
10
5
|
case "true":
|
|
@@ -17,8 +12,7 @@ function o(e) {
|
|
|
17
12
|
default:
|
|
18
13
|
return !1;
|
|
19
14
|
}
|
|
20
|
-
}
|
|
21
|
-
function t(e) {
|
|
15
|
+
}, c = (e) => {
|
|
22
16
|
switch (e.toLowerCase()) {
|
|
23
17
|
case "true":
|
|
24
18
|
case "1":
|
|
@@ -29,16 +23,13 @@ function t(e) {
|
|
|
29
23
|
case "off":
|
|
30
24
|
return !1;
|
|
31
25
|
default:
|
|
32
|
-
throw new
|
|
26
|
+
throw new a(`unable to parse '${e}' to boolean`);
|
|
33
27
|
}
|
|
34
|
-
}
|
|
35
|
-
function s(e, r) {
|
|
36
|
-
return e !== r;
|
|
37
|
-
}
|
|
28
|
+
}, l = (e, o) => e !== o;
|
|
38
29
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
t as booleanToInt,
|
|
31
|
+
n as canParseBoolean,
|
|
32
|
+
r as compareBooleans,
|
|
33
|
+
c as parseBoolean,
|
|
34
|
+
l as xorBoolean
|
|
44
35
|
};
|
package/equal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=(e,t)=>e===t||e!==e&&t!==t,f=(e,t)=>{if(g(e,t))return!0;if(e==null||t==null)return!1;const l=Array.isArray(e),h=Array.isArray(t);if(l!==h)return!1;if(l){const s=e,n=t,a=s.length;if(a!==n.length)return!1;for(let r=0;r<a;r++)if(!f(s[r],n[r]))return!1;return!0}const u=e instanceof Date,j=t instanceof Date;if(u!==j)return!1;if(u){const s=e,n=t;return+s==+n}const p=e instanceof Set,I=t instanceof Set;if(p!==I)return!1;if(p){const s=e,n=t;if(s.size!==n.size)return!1;const a=s.keys();for(;;){const r=a.next();if(r.done??!1)break;if(!n.has(r.value))return!1}return!0}const y=e instanceof Map,O=t instanceof Map;if(y!==O)return!1;if(y){const s=e,n=t;if(s.size!==n.size)return!1;const r=s.keys();for(;;){const o=r.next();if(o.done??!1)break;if(!f(s.get(o.value),n.get(o.value)))return!1}return!0}const b=typeof e=="object";if(b!==(typeof t=="object"))return!1;if(b){const s=e,n=t,a=Object.keys(s),r=Object.keys(n),o=a.length;if(o!==r.length)return!1;for(let c=0;c<o;c++){const i=a[c];if(!Object.prototype.hasOwnProperty.call(n,i)||!f(s[i],n[i]))return!1}return!0}return!1},d=(e,t)=>e==t;exports.deepEqual=f;exports.looseEqual=d;exports.strictEqual=g;
|
package/equal.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @returns `true` if the values are strictly equal, `false` otherwise.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export declare
|
|
10
|
+
export declare const strictEqual: <A>(a: A, b: A) => boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Checks if two values are equal by comparing their contents.
|
|
13
13
|
*
|
|
@@ -17,7 +17,7 @@ export declare function strictEqual<A>(a: A, b: A): boolean;
|
|
|
17
17
|
* @returns `true` if the values are deeply equal, `false` otherwise.
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
|
-
export declare
|
|
20
|
+
export declare const deepEqual: <A>(a: A, b: A) => boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Checks if two values are loosely equal.
|
|
23
23
|
*
|
|
@@ -26,4 +26,4 @@ export declare function deepEqual<A>(a: A, b: A): boolean;
|
|
|
26
26
|
* @returns `true` if the values are loosely equal, `false` otherwise.
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
|
-
export declare
|
|
29
|
+
export declare const looseEqual: <T>(a: T, b: T) => boolean;
|