altcha-lib 0.4.0 → 0.4.1

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/cjs/dist/index.js CHANGED
@@ -117,12 +117,7 @@ function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6, start
117
117
  exports.solveChallenge = solveChallenge;
118
118
  async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) {
119
119
  const workers = [];
120
- if (concurrency < 1) {
121
- throw new Error('Wrong number of workers configured.');
122
- }
123
- if (concurrency > 16) {
124
- throw new Error('Too many workers. Max. 16 allowed workers.');
125
- }
120
+ concurrency = Math.min(1, Math.max(16, concurrency));
126
121
  for (let i = 0; i < concurrency; i++) {
127
122
  if (typeof workerScript === 'function') {
128
123
  workers.push(workerScript());
package/dist/index.js CHANGED
@@ -109,12 +109,7 @@ export function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6
109
109
  }
110
110
  export async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) {
111
111
  const workers = [];
112
- if (concurrency < 1) {
113
- throw new Error('Wrong number of workers configured.');
114
- }
115
- if (concurrency > 16) {
116
- throw new Error('Too many workers. Max. 16 allowed workers.');
117
- }
112
+ concurrency = Math.min(1, Math.max(16, concurrency));
118
113
  for (let i = 0; i < concurrency; i++) {
119
114
  if (typeof workerScript === 'function') {
120
115
  workers.push(workerScript());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "altcha-lib",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "A library for creating and verifying ALTCHA challenges for Node.js, Bun and Deno.",
5
5
  "author": "Daniel Regeci",
6
6
  "license": "MIT",