diff --git a/cjs/dist/index.js b/cjs/dist/index.js index 99af199..c2aa99e 100644 --- a/cjs/dist/index.js +++ b/cjs/dist/index.js @@ -196,7 +196,7 @@ function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6, start */ async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) { const workers = []; - concurrency = Math.min(1, Math.max(16, concurrency)); + concurrency = Math.max(1, Math.min(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 1693c74..5c8e40f 100644 --- a/deno_dist/index.ts +++ b/deno_dist/index.ts @@ -251,7 +251,7 @@ export async function solveChallengeWorkers( startNumber: number = 0 ): Promise { const workers: Worker[] = []; - concurrency = Math.min(1, Math.max(16, concurrency)); + concurrency = Math.max(1, Math.min(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 b37e5c8..000b322 100644 --- a/dist/index.js +++ b/dist/index.js @@ -187,7 +187,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 = []; - concurrency = Math.min(1, Math.max(16, concurrency)); + concurrency = Math.max(1, Math.min(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 b31682a..321f13c 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -251,7 +251,7 @@ export async function solveChallengeWorkers( startNumber: number = 0 ): Promise { const workers: Worker[] = []; - concurrency = Math.min(1, Math.max(16, concurrency)); + concurrency = Math.max(1, Math.min(16, concurrency)); for (let i = 0; i < concurrency; i++) { if (typeof workerScript === 'function') { workers.push(workerScript());