Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
A tiny wrapper for turning Node.js threads in easy-to-use routines for CPU-bound.
When my multithreaded program works like a charm - thecodinglove
Microjob is a tiny wrapper for Node.js threads and is intended to perform heavy CPU loads using anonymous functions.
So, Microjob treats Node.js threads as temporary working units: if you need to spawn a long-living thread, then you should use the default API.
From version v0.1.0 microjob uses a Worker Pool 🎉
Microjob follows the same line of the original Node.js documentation: use it only for CPU-bound jobs and not for I/O-bound purposes. Quoting the documentation:
Workers are useful for performing CPU-intensive JavaScript operations; do not use them for I/O, since Node.js’s built-in mechanisms for performing operations asynchronously already treat it more efficiently than Worker threads can.
Microjob can be used only with Node.js 10.5+ and with the --experimental-worker flag activated, otherwise it won't work.
More details explained in: Microjob: a tiny multithreading library for Node.js
Via npm:
$ npm install --save microjob
(async () => {
const { job, start, stop } = require("microjob");
try {
// start the worker pool
await start();
// this function will be executed in another thread
const res = await job(() => {
let i = 0;
for (i = 0; i < 1000000; i++) {
// heavy CPU load ...
}
return i;
});
console.log(res); // 1000000
} catch (err) {
console.error(err);
} finally {
// shutdown worker pool
await stop();
}
})();
Dive deep into the documentation to find more examples: Guide
FAQs
A tiny wrapper for Node.js worker_threads lib
The npm package microjob receives a total of 2,875 weekly downloads. As such, microjob popularity was classified as popular.
We found that microjob 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.