Skip to content

Commit

Permalink
fix: concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
ovx committed Nov 14, 2024
1 parent 9c2f83f commit 2abecd9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cjs/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export async function solveChallengeWorkers(
startNumber: number = 0
): Promise<Solution | null> {
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());
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export async function solveChallengeWorkers(
startNumber: number = 0
): Promise<Solution | null> {
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());
Expand Down

0 comments on commit 2abecd9

Please sign in to comment.