@tktb-tess/util-fns 0.5.1 → 0.6.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 +21 -21
- package/README.md +30 -31
- package/dist/brand.d.ts +0 -7
- package/dist/bundle.js +9 -10
- package/dist/executer.d.ts +1 -1
- package/dist/main.d.ts +0 -1
- package/dist/util.d.ts +8 -2
- package/package.json +15 -18
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Tessyrrhaqt
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tessyrrhaqt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
# util-fns
|
|
2
|
-
|
|
3
|
-
Utility functions for personal use
|
|
4
|
-
|
|
5
|
-
ESM only
|
|
6
|
-
|
|
7
|
-
Available in both a browser and Node.js environment.
|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm i @tktb-tess/util-fns
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Usage
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { modPow } from '@tktb-tess/util-fns';
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
# util-fns
|
|
2
|
+
|
|
3
|
+
Utility functions for personal use
|
|
4
|
+
|
|
5
|
+
ESM only
|
|
6
|
+
|
|
7
|
+
Available in both a browser and Node.js environment.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @tktb-tess/util-fns
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { modPow, bailliePSW } from '@tktb-tess/util-fns';
|
|
19
|
+
|
|
20
|
+
const ans = modPow(2n, 16n, 17n);
|
|
21
|
+
console.log(ans); // 1n
|
|
22
|
+
|
|
23
|
+
// Baillie-PSW primality test
|
|
24
|
+
console.log(bailliePSW(2n)); // true
|
|
25
|
+
console.log(bailliePSW(4n)): // false
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
package/dist/brand.d.ts
CHANGED
package/dist/bundle.js
CHANGED
|
@@ -258,7 +258,7 @@ const V = (n) => {
|
|
|
258
258
|
u = d(u * u - 2n * r, n), r = p(r, 2n, n);
|
|
259
259
|
}
|
|
260
260
|
return !1;
|
|
261
|
-
},
|
|
261
|
+
}, A = (n) => {
|
|
262
262
|
if (n <= 1n) return !1;
|
|
263
263
|
if (n % 2n === 0n) return n === 2n;
|
|
264
264
|
const t = [
|
|
@@ -303,7 +303,7 @@ const V = (n) => {
|
|
|
303
303
|
throw Error("noPrimesFound");
|
|
304
304
|
for (let r = 0; r < 1e5; r++) {
|
|
305
305
|
const s = P(n, t);
|
|
306
|
-
if (
|
|
306
|
+
if (A(s)) return s;
|
|
307
307
|
}
|
|
308
308
|
throw Error("noPrimesFound");
|
|
309
309
|
}, Y = (n, t = !1) => {
|
|
@@ -311,7 +311,7 @@ const V = (n) => {
|
|
|
311
311
|
throw Error("noPrimesFound");
|
|
312
312
|
for (let r = 0; r < 1e5; r++) {
|
|
313
313
|
const s = b(n, t);
|
|
314
|
-
if (
|
|
314
|
+
if (A(s)) return s;
|
|
315
315
|
}
|
|
316
316
|
throw Error("noPrimesFound");
|
|
317
317
|
};
|
|
@@ -474,15 +474,15 @@ const Q = (n) => {
|
|
|
474
474
|
t > 0 && (n = n + "=".repeat(4 - t));
|
|
475
475
|
const e = n.replaceAll("-", "+").replaceAll("_", "/");
|
|
476
476
|
return L(e);
|
|
477
|
-
}
|
|
478
|
-
class
|
|
477
|
+
};
|
|
478
|
+
class B {
|
|
479
479
|
#t;
|
|
480
480
|
#n = [];
|
|
481
481
|
static get name() {
|
|
482
482
|
return "Queue";
|
|
483
483
|
}
|
|
484
484
|
get [Symbol.toStringTag]() {
|
|
485
|
-
return
|
|
485
|
+
return B.name;
|
|
486
486
|
}
|
|
487
487
|
constructor(...t) {
|
|
488
488
|
this.#t = t;
|
|
@@ -532,7 +532,7 @@ class N {
|
|
|
532
532
|
};
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
|
-
|
|
535
|
+
get() {
|
|
536
536
|
switch (this.#t.state) {
|
|
537
537
|
case "fulfilled":
|
|
538
538
|
return this.#t.data;
|
|
@@ -560,12 +560,11 @@ class N {
|
|
|
560
560
|
}
|
|
561
561
|
export {
|
|
562
562
|
Q as BItoU8Arr,
|
|
563
|
-
rt as Brand,
|
|
564
563
|
N as Executer,
|
|
565
564
|
I as PCGMinimal,
|
|
566
|
-
|
|
565
|
+
B as Queue,
|
|
567
566
|
f as Rational,
|
|
568
|
-
|
|
567
|
+
A as bailliePSW,
|
|
569
568
|
L as base64ToU8Arr,
|
|
570
569
|
et as base64UrlToU8Arr,
|
|
571
570
|
z as decodeRFC3986URIComponent,
|
package/dist/executer.d.ts
CHANGED
|
@@ -13,6 +13,6 @@ export declare class Executer<T> {
|
|
|
13
13
|
static get name(): 'Executer';
|
|
14
14
|
get [Symbol.toStringTag](): "Executer";
|
|
15
15
|
constructor(promise: Promise<T>);
|
|
16
|
-
|
|
16
|
+
get(): T;
|
|
17
17
|
static boundary<TArg extends unknown[]>(func: (...args: TArg) => void): (...args: TArg) => void;
|
|
18
18
|
}
|
package/dist/main.d.ts
CHANGED
package/dist/util.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compare two objects with SameValueZero method
|
|
3
|
+
* @param a
|
|
4
|
+
* @param b
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
1
7
|
declare const sameValueZero: (a: unknown, b: unknown) => boolean;
|
|
2
8
|
/**
|
|
3
9
|
* judges whether two objects has the same (nested) properties \
|
|
@@ -20,12 +26,12 @@ declare const promiseWithResolvers: <T>() => {
|
|
|
20
26
|
*/
|
|
21
27
|
declare const sleep: (delay: number) => Promise<void>;
|
|
22
28
|
/**
|
|
23
|
-
* makes a function
|
|
29
|
+
* makes a function lazy
|
|
24
30
|
*/
|
|
25
31
|
declare const lazify: <ArgT extends unknown[], RetT>(func: (...args: ArgT) => RetT) => (...args: ArgT) => () => RetT;
|
|
26
32
|
/**
|
|
27
33
|
* parses CSV string \
|
|
28
|
-
*
|
|
34
|
+
* able to deal with CSV with escaping doublequote
|
|
29
35
|
* @param csv CSV
|
|
30
36
|
* @returns 2次元配列
|
|
31
37
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tktb-tess/util-fns",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Utility functions for personal use",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"author": "Tessyrrhaqt",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
|
-
},
|
|
14
11
|
"main": "./dist/bundle.js",
|
|
15
12
|
"types": "./dist/main.d.ts",
|
|
16
13
|
"exports": {
|
|
@@ -18,30 +15,30 @@
|
|
|
18
15
|
"import": "./dist/bundle.js"
|
|
19
16
|
},
|
|
20
17
|
"engines": {
|
|
21
|
-
"node": "^22
|
|
18
|
+
"node": "^22",
|
|
19
|
+
"pnpm": "^10"
|
|
22
20
|
},
|
|
23
21
|
"repository": {
|
|
24
22
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/tktb-tess/util-fns"
|
|
23
|
+
"url": "https://github.com/tktb-tess/util-fns.git"
|
|
26
24
|
},
|
|
27
25
|
"homepage": "https://github.com/tktb-tess/util-fns/blob/main/README.md",
|
|
28
|
-
"scripts": {
|
|
29
|
-
"dev": "vite",
|
|
30
|
-
"build": "tsc && vite build",
|
|
31
|
-
"test": "vitest run",
|
|
32
|
-
"typecheck": "tsc --noEmit"
|
|
33
|
-
},
|
|
34
26
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^24.
|
|
27
|
+
"@types/node": "^24.6.2",
|
|
36
28
|
"jsdom": "^26.1.0",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"vite": "^7.1.3",
|
|
29
|
+
"tsx": "^4.20.6",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"vite": "^7.1.9",
|
|
41
32
|
"vite-plugin-dts": "^4.5.4",
|
|
42
33
|
"vitest": "^3.2.4"
|
|
43
34
|
},
|
|
44
35
|
"volta": {
|
|
45
36
|
"node": "22.19.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"dev": "vite",
|
|
40
|
+
"build": "tsc && vite build",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"typecheck": "tsc --noEmit"
|
|
46
43
|
}
|
|
47
|
-
}
|
|
44
|
+
}
|