Error handling and unit tests
[poolifier.git] / examples / multifunctionWorker.js
1 'use strict'
2 const { ThreadWorker } = require('../lib/workers')
3
4 function yourFunction (data) {
5 if (data.fname === 'fn0') {
6 console.log('Executing function 0')
7 return { data: '0 your input was' + data.input }
8 } else if (data.fname === 'fn1') {
9 console.log('Executing function 1')
10 return { data: '1 your input was' + data.input }
11 }
12 }
13
14 class MyWorker extends ThreadWorker {
15 constructor () {
16 super(yourFunction)
17 }
18 }
19 module.exports = new MyWorker()