cluster.js

1.0.0 • Public • Published

cluster.js

Little helper for clustering functions across your cpu cores.

Install

yarn add cluster.js

Example

const cluster = require('cluster.js')
 
const tasks = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l' ]
 
cluster(tasks, function (task) {
  console.log('calculating', task)
  const fib = fibonacci(40)
  console.log('calculated', task)
  return { task: task, n: fib }
})
  .then(console.log)
  .catch(console.error)
 
function fibonacci (n) {
  if (< 2) return 1
  return fibonacci(- 2) + fibonacci(- 1)
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i cluster.js

Weekly Downloads

3

Version

1.0.0

License

none

Last publish

Collaborators

  • mattmueller