Learning to swim with Piscina.js

June 04, 2020

Piscina is an open source worker thread pool implementation for Node.js. Read More: https://www.nearform.com/blog/learning-to-swim-with-piscina-the-node-js-worker-pool/

See the code: https://github.com/piscinajs/piscina

$ npm install piscina
$ yarn add piscina
example.js
const Piscina = require('piscina');

const piscina = new Piscina({
  filename: path.resolve(__dirname, 'worker.js');
});

(async function() {
  const result = await piscina.run({ a: 4, b: 6 });
  console.log(result);  // Prints 10
})();