0.1.0 • Published 3 years ago

threadevents v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

threadevents

A simple wrapper for worker_threads

Example

index.js:

const { Worker } = require("worker_threads");

const EventThread = require("threadevents");

const thread = new EventThread(new Worker("./worker.js"));

thread.once('res',console.log);
thread.emit('calculate',50e9,100e9)

worker.js:

const main = require("threadevents/worker");

main.on('calculate',(x,y) => {
    main.emit("res",x+y);
})

Running this example should output: 150000000000 in your terminal/console