Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
multee
Advanced tools
Readme
multee is a "battery" API. It turns node's multitasking modules, namingly child_process
and worker_threads
, into simple async functions.
Without multee
, you need to listen to messages from your threads/processes, and it is hard to integrate the listener to other part of your code. Also, when there are multiple operations inside the worker, we have to implement the dispatching logic inside the message listener.
The code will look like below without multee
// worker.js
process.on('message', (msg) => {
// do heavy load job
process.send(job_result)
})
// master.js
const child = fork('./worker')
process.on('message', (msg) => {
// if is job result
part2(msg)
})
function part1() {
child.send(payload_for_worker)
}
function part2(result) {
// do the rest with result
}
And with multee
, it's just as easy as calling an async function.
// worker.js
const Multee = require('multee')
const multee = Multee('worker') // worker_threads, use 'child' for child_process
export const jobA = multee.createHandler('jobA', () => {
// do the heavy load here
})
module.exports = () => {
const worker = multee.start(__filename)
return { test: jobA(worker) }
}
// master.js
async function partA() {
const worker = require('./worker')
const result = await worker.jobA()
// do the rest with result
}
multee
works with Typescript. As you can't directly start worker_threads from Typescript, multee
includes the battery to handle that. note: ts-node
needed as a peer dependency when using Typescript.
MIT
FAQs
Turn node's multitasking modules, child_process and worker_threads into simple async functions
The npm package multee receives a total of 780 weekly downloads. As such, multee popularity was classified as not popular.
We found that multee 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.