threadevents

0.1.0 • Public • Published

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

/threadevents/

    Package Sidebar

    Install

    npm i threadevents

    Weekly Downloads

    5

    Version

    0.1.0

    License

    ISC

    Unpacked Size

    2.45 kB

    Total Files

    6

    Last publish

    Collaborators

    • kagamox