mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-17 05:44:57 +00:00
fix(js/algorithms/fast): handle old browsers
Closes #1082 Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -5,13 +5,16 @@ interface ProcessOptions {
|
|||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getHardwareConcurrency = () =>
|
||||||
|
navigator.hardwareConcurrency !== undefined ? navigator.hardwareConcurrency : 1;
|
||||||
|
|
||||||
export default function process(
|
export default function process(
|
||||||
options: ProcessOptions,
|
options: ProcessOptions,
|
||||||
data: string,
|
data: string,
|
||||||
difficulty: number = 5,
|
difficulty: number = 5,
|
||||||
signal: AbortSignal | null = null,
|
signal: AbortSignal | null = null,
|
||||||
progressCallback?: ProgressCallback,
|
progressCallback?: ProgressCallback,
|
||||||
threads: number = Math.trunc(Math.max(navigator.hardwareConcurrency / 2, 1)),
|
threads: number = Math.trunc(Math.max(getHardwareConcurrency() / 2, 1)),
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
console.debug("fast algo");
|
console.debug("fast algo");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user