1.1.0 • Published 7 years ago

worker-thread v1.1.0

Weekly downloads
112
License
MIT
Repository
github
Last release
7 years ago

worker-thread

Worker Thread Pattern for Node.js

$ npm install worker-thread

Required

  • Node
    • version >=4

Sample

const wt = require("worker-thread");

function worker(n) {
  return new Promise(r => {
    const second = Math.floor((Math.random() * 6));
    setTimeout(() => r(`delay ${second}s: ${n}`), second * 1000);
  });
}

const ch = wt.createChannel(worker, 10);

ch.on("done", (err, result) => {
  if (err) {
    console.error(err);
  }

  console.log(result);
});

ch.on("stop", () => {
  console.log("channel is stop");
});

let i = 0;
while(i < 10) {
  ch.add(i++);
}
1.1.0

7 years ago

1.0.0

7 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago