Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
web-worker-helper
Advanced tools
Forked from @loaders.gl/worker-utils refactoring
// fibonacci.js
export function fibonacci(n: number) {
let n1 = 1,
n2 = 1,
sum = 1;
for (let i = 3; i <= n; i += 1) {
sum = n1 + n2;
n1 = n2;
n2 = sum;
}
return sum;
}
// fibonacci.worker.js
import { createWorker } from 'web-worker-helper';
import { fibonacci } from './fibonacci';
createWorker(async (data: number, options?: Record<string, any>) => {
const result = fibonacci(data);
return result;
});
import { getWorkerURL, WorkerFarm } from "17-worker";
export async function parseWorker(workerName: string, data: any, options?: Record<string, any> ) {
const url = getWorkerURL (workerName, options);
const workerFarm = WorkerFarm.getWorkerFarm({ maxConcurrency: 3, reuseWorkers: true });
const workerPool = workerFarm.getWorkerPool({ name: workerName, url })
// const workerPool = workerController.getWorkerPool({ name: workerName, url });
const job = await workerPool.startJob(workerName, (job, type, data) => job.done(data));
job.postMessage('process', { input: data })
const result = await job.result;
return result.result;
import { parseWorker } from '17-worker';
import { fibonacci } from './fibonacci';
export async function starFibonacci(iskorker, data) {
if (iskorker) {
const result = await parseWorker('fibonacci-worker', data, {});
return result;
}
const result = await fibonacci(data);
return result;
}
FAQs
Utilities for running tasks on worker threads
The npm package web-worker-helper receives a total of 23,343 weekly downloads. As such, web-worker-helper popularity was classified as popular.
We found that web-worker-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.