
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
web-worker-helper
Advanced tools
Forked from @loaders.gl/worker-utils implementation
// 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) => {
const result = fibonacci(data);
return result;
});
import { WorkerFarm } from 'web-worker-helper';
export async function parseWorker(
workerName: string,
data: any,
options?: Record<string, any> = { maxConcurrency: 3, reuseWorkers: true }
) {
const url = getWorkerURL({ name: workerName });
// const source = `fibonacci codeString`
const workerFarm = WorkerFarm.getWorkerFarm({
maxConcurrency: options.maxConcurrency,
reuseWorkers: options.reuseWorkers,
});
const workerPool = workerFarm.getWorkerPool({ name: workerName, url });
// const workerPool = workerFarm.getWorkerPool({ name: workerName, source });
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 './parse-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 0 weekly downloads. As such, web-worker-helper popularity was classified as not popular.
We found that web-worker-helper demonstrated a not healthy version release cadence and project activity because the last version was released 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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.