altcha-lib 0.1.3 → 0.1.4
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 +11 -9
- package/cjs/dist/index.d.ts +1 -1
- package/cjs/dist/index.js +8 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ ALTCHA JS Library is a lightweight, zero-dependency library designed for creatin
|
|
|
4
4
|
|
|
5
5
|
## Compatibility
|
|
6
6
|
|
|
7
|
-
This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and
|
|
7
|
+
This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and can be used in modern browsers and supported server environments:
|
|
8
8
|
|
|
9
9
|
- Node.js 16+
|
|
10
10
|
- Bun 1+
|
|
@@ -103,16 +103,18 @@ const solution = await solveChallengeWorkers(
|
|
|
103
103
|
|
|
104
104
|
```
|
|
105
105
|
> solveChallenge()
|
|
106
|
-
- n = 1,000...............................
|
|
107
|
-
- n = 10,000..............................
|
|
108
|
-
- n =
|
|
109
|
-
- n =
|
|
106
|
+
- n = 1,000............................... 319 ops/s ±2.04%
|
|
107
|
+
- n = 10,000.............................. 31 ops/s ±1.02%
|
|
108
|
+
- n = 50,000.............................. 6 ops/s ±1.48%
|
|
109
|
+
- n = 100,000............................. 3 ops/s ±0.27%
|
|
110
|
+
- n = 500,000............................. 0 ops/s ±0.36%
|
|
110
111
|
|
|
111
112
|
> solveChallengeWorkers() (8 workers)
|
|
112
|
-
- n = 1,000...............................
|
|
113
|
-
- n = 10,000..............................
|
|
114
|
-
- n =
|
|
115
|
-
- n =
|
|
113
|
+
- n = 1,000............................... 62 ops/s ±5.69%
|
|
114
|
+
- n = 10,000.............................. 30 ops/s ±4.35%
|
|
115
|
+
- n = 50,000.............................. 12 ops/s ±2.89%
|
|
116
|
+
- n = 100,000............................. 7 ops/s ±2.33%
|
|
117
|
+
- n = 500,000............................. 1 ops/s ±2.22%
|
|
116
118
|
```
|
|
117
119
|
|
|
118
120
|
Run with Bun on MacBook Pro M3-Pro. See [/benchmark](/benchmark/) folder for more details.
|
package/cjs/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare function solveChallenge(challenge: string, salt: string, algorith
|
|
|
5
5
|
promise: Promise<Solution | null>;
|
|
6
6
|
controller: AbortController;
|
|
7
7
|
};
|
|
8
|
-
export declare function solveChallengeWorkers(workerScript: string | URL, concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise<Solution | null>;
|
|
8
|
+
export declare function solveChallengeWorkers(workerScript: string | URL | (() => Worker), concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise<Solution | null>;
|
package/cjs/dist/index.js
CHANGED
|
@@ -76,9 +76,14 @@ async function solveChallengeWorkers(workerScript, concurrency, challenge, salt,
|
|
|
76
76
|
throw new Error('Too many workers. Max. 16 allowed workers.');
|
|
77
77
|
}
|
|
78
78
|
for (let i = 0; i < concurrency; i++) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
79
|
+
if (typeof workerScript === 'function') {
|
|
80
|
+
workers.push(workerScript());
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
workers.push(new Worker(workerScript, {
|
|
84
|
+
type: 'module',
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
const step = Math.ceil(max / concurrency);
|
|
84
89
|
const solutions = await Promise.all(workers.map((worker, i) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare function solveChallenge(challenge: string, salt: string, algorith
|
|
|
5
5
|
promise: Promise<Solution | null>;
|
|
6
6
|
controller: AbortController;
|
|
7
7
|
};
|
|
8
|
-
export declare function solveChallengeWorkers(workerScript: string | URL, concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise<Solution | null>;
|
|
8
|
+
export declare function solveChallengeWorkers(workerScript: string | URL | (() => Worker), concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise<Solution | null>;
|
package/dist/index.js
CHANGED
|
@@ -70,9 +70,14 @@ export async function solveChallengeWorkers(workerScript, concurrency, challenge
|
|
|
70
70
|
throw new Error('Too many workers. Max. 16 allowed workers.');
|
|
71
71
|
}
|
|
72
72
|
for (let i = 0; i < concurrency; i++) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
73
|
+
if (typeof workerScript === 'function') {
|
|
74
|
+
workers.push(workerScript());
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
workers.push(new Worker(workerScript, {
|
|
78
|
+
type: 'module',
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
76
81
|
}
|
|
77
82
|
const step = Math.ceil(max / concurrency);
|
|
78
83
|
const solutions = await Promise.all(workers.map((worker, i) => {
|