Fix when hardwareConcurrency is undefined (#42)

This commit is contained in:
Callum Thomson 2025-03-21 12:51:19 +00:00 committed by GitHub
parent 94f43c7200
commit f1220ecc57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,6 @@
// https://dev.to/ratmd/simple-proof-of-work-in-javascript-3kgm
export function process(data, difficulty = 5, threads = navigator.hardwareConcurrency) {
export function process(data, difficulty = 5, threads = (navigator.hardwareConcurrency || 1)) {
return new Promise((resolve, reject) => {
let webWorkerURL = URL.createObjectURL(new Blob([
'(', processTask(), ')()'