@tempots/std 0.13.0 → 0.14.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 +108 -167
- package/async-result.d.ts +15 -15
- 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 +116 -114
- 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.d.ts +8 -8
- package/string.cjs +4 -4
- package/string.d.ts +85 -89
- package/string.js +193 -379
- package/validation.d.ts +7 -7
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.
|
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;
|
package/equal.js
CHANGED
|
@@ -1,66 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
return e === t || e !== e && t !== t;
|
|
3
|
-
}
|
|
4
|
-
function i(e, t) {
|
|
1
|
+
const O = (e, t) => e === t || e !== e && t !== t, i = (e, t) => {
|
|
5
2
|
if (O(e, t)) return !0;
|
|
6
3
|
if (e == null || t == null) return !1;
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
const
|
|
11
|
-
if (a !==
|
|
12
|
-
for (let
|
|
13
|
-
if (!i(
|
|
4
|
+
const l = Array.isArray(e), b = Array.isArray(t);
|
|
5
|
+
if (l !== b) return !1;
|
|
6
|
+
if (l) {
|
|
7
|
+
const s = e, n = t, a = s.length;
|
|
8
|
+
if (a !== n.length) return !1;
|
|
9
|
+
for (let r = 0; r < a; r++)
|
|
10
|
+
if (!i(s[r], n[r])) return !1;
|
|
14
11
|
return !0;
|
|
15
12
|
}
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
return +
|
|
13
|
+
const u = e instanceof Date, I = t instanceof Date;
|
|
14
|
+
if (u !== I) return !1;
|
|
15
|
+
if (u) {
|
|
16
|
+
const s = e, n = t;
|
|
17
|
+
return +s == +n;
|
|
21
18
|
}
|
|
22
19
|
const p = e instanceof Set, g = t instanceof Set;
|
|
23
20
|
if (p !== g) return !1;
|
|
24
21
|
if (p) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
const a =
|
|
22
|
+
const s = e, n = t;
|
|
23
|
+
if (s.size !== n.size) return !1;
|
|
24
|
+
const a = s.keys();
|
|
28
25
|
for (; ; ) {
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
if (!
|
|
26
|
+
const r = a.next();
|
|
27
|
+
if (r.done ?? !1) break;
|
|
28
|
+
if (!n.has(r.value)) return !1;
|
|
32
29
|
}
|
|
33
30
|
return !0;
|
|
34
31
|
}
|
|
35
32
|
const h = e instanceof Map, j = t instanceof Map;
|
|
36
33
|
if (h !== j) return !1;
|
|
37
34
|
if (h) {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
35
|
+
const s = e, n = t;
|
|
36
|
+
if (s.size !== n.size) return !1;
|
|
37
|
+
const r = s.keys();
|
|
41
38
|
for (; ; ) {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
if (!i(
|
|
39
|
+
const o = r.next();
|
|
40
|
+
if (o.done ?? !1) break;
|
|
41
|
+
if (!i(s.get(o.value), n.get(o.value))) return !1;
|
|
45
42
|
}
|
|
46
43
|
return !0;
|
|
47
44
|
}
|
|
48
45
|
const y = typeof e == "object";
|
|
49
46
|
if (y !== (typeof t == "object")) return !1;
|
|
50
47
|
if (y) {
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
for (let
|
|
54
|
-
const c = a[
|
|
55
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
48
|
+
const s = e, n = t, a = Object.keys(s), r = Object.keys(n), o = a.length;
|
|
49
|
+
if (o !== r.length) return !1;
|
|
50
|
+
for (let f = 0; f < o; f++) {
|
|
51
|
+
const c = a[f];
|
|
52
|
+
if (!Object.prototype.hasOwnProperty.call(n, c) || !i(s[c], n[c])) return !1;
|
|
56
53
|
}
|
|
57
54
|
return !0;
|
|
58
55
|
}
|
|
59
56
|
return !1;
|
|
60
|
-
}
|
|
61
|
-
function M(e, t) {
|
|
62
|
-
return e == t;
|
|
63
|
-
}
|
|
57
|
+
}, M = (e, t) => e == t;
|
|
64
58
|
export {
|
|
65
59
|
i as deepEqual,
|
|
66
60
|
M as looseEqual,
|
package/error.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o extends Error{constructor(r="Operation aborted"){super(r),this.name="AbortError"}}class s extends Error{constructor(r="Missing implementation"){super(r),this.name="MissingImplementationError"}}class e extends Error{constructor(r){super(r),this.name="ParsingError"}}class n extends Error{constructor(r){super(r),this.name="ArgumentError"}}exports.AbortError=o;exports.ArgumentError=n;exports.MissingImplementationError=s;exports.ParsingError=e;
|
package/error.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an error that is thrown when an operation is aborted.
|
|
3
|
+
*/
|
|
4
|
+
export declare class AbortError extends Error {
|
|
5
|
+
constructor(message?: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Represents an error that is thrown when a required implementation is missing.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MissingImplementationError extends Error {
|
|
11
|
+
constructor(message?: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents an error that occurs during parsing.
|
|
15
|
+
*/
|
|
16
|
+
export declare class ParsingError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents an error that occurs when an invalid argument is passed to a function or method.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ArgumentError extends Error {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
package/error.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class t extends Error {
|
|
2
|
+
constructor(r = "Operation aborted") {
|
|
3
|
+
super(r), this.name = "AbortError";
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
class o extends Error {
|
|
7
|
+
constructor(r = "Missing implementation") {
|
|
8
|
+
super(r), this.name = "MissingImplementationError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
class e extends Error {
|
|
12
|
+
constructor(r) {
|
|
13
|
+
super(r), this.name = "ParsingError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class n extends Error {
|
|
17
|
+
constructor(r) {
|
|
18
|
+
super(r), this.name = "ArgumentError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
t as AbortError,
|
|
23
|
+
n as ArgumentError,
|
|
24
|
+
o as MissingImplementationError,
|
|
25
|
+
e as ParsingError
|
|
26
|
+
};
|
package/function.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 i=e=>e,o=e=>t=>(...r)=>e(t,...r),n=e=>{let t;return()=>(t===void 0&&(t=e()),t)};exports.curryLeft=o;exports.identity=i;exports.memoize=n;
|