From 42bf72f883266ee6fe7decc7be2c40a4842d4097 Mon Sep 17 00:00:00 2001 From: Daniel Regeci <536331+ovx@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:16:26 -0300 Subject: [PATCH] 0.4.1 --- cjs/dist/index.js | 7 +------ deno_dist/index.ts | 7 +------ dist/index.js | 7 +------ lib/index.ts | 7 +------ package.json | 2 +- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/cjs/dist/index.js b/cjs/dist/index.js index c457650..a1573e1 100644 --- a/cjs/dist/index.js +++ b/cjs/dist/index.js @@ -117,12 +117,7 @@ function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6, start exports.solveChallenge = solveChallenge; async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) { const workers = []; - if (concurrency < 1) { - throw new Error('Wrong number of workers configured.'); - } - if (concurrency > 16) { - throw new Error('Too many workers. Max. 16 allowed workers.'); - } + concurrency = Math.min(1, Math.max(16, concurrency)); for (let i = 0; i < concurrency; i++) { if (typeof workerScript === 'function') { workers.push(workerScript()); diff --git a/deno_dist/index.ts b/deno_dist/index.ts index 783d600..ac80158 100644 --- a/deno_dist/index.ts +++ b/deno_dist/index.ts @@ -163,12 +163,7 @@ export async function solveChallengeWorkers( startNumber: number = 0 ) { const workers: Worker[] = []; - if (concurrency < 1) { - throw new Error('Wrong number of workers configured.'); - } - if (concurrency > 16) { - throw new Error('Too many workers. Max. 16 allowed workers.'); - } + concurrency = Math.min(1, Math.max(16, concurrency)); for (let i = 0; i < concurrency; i++) { if (typeof workerScript === 'function') { workers.push(workerScript()); diff --git a/dist/index.js b/dist/index.js index 04c6ef0..7c06f2f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -109,12 +109,7 @@ export function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6 } export async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) { const workers = []; - if (concurrency < 1) { - throw new Error('Wrong number of workers configured.'); - } - if (concurrency > 16) { - throw new Error('Too many workers. Max. 16 allowed workers.'); - } + concurrency = Math.min(1, Math.max(16, concurrency)); for (let i = 0; i < concurrency; i++) { if (typeof workerScript === 'function') { workers.push(workerScript()); diff --git a/lib/index.ts b/lib/index.ts index e279ee1..9f0ca93 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -163,12 +163,7 @@ export async function solveChallengeWorkers( startNumber: number = 0 ) { const workers: Worker[] = []; - if (concurrency < 1) { - throw new Error('Wrong number of workers configured.'); - } - if (concurrency > 16) { - throw new Error('Too many workers. Max. 16 allowed workers.'); - } + concurrency = Math.min(1, Math.max(16, concurrency)); for (let i = 0; i < concurrency; i++) { if (typeof workerScript === 'function') { workers.push(workerScript()); diff --git a/package.json b/package.json index 818689c..0721d22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "altcha-lib", - "version": "0.4.0", + "version": "0.4.1", "description": "A library for creating and verifying ALTCHA challenges for Node.js, Bun and Deno.", "author": "Daniel Regeci", "license": "MIT",