X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultifunctionWorker.js;h=53217fa04957821ec4def7bca47b4334e21bf4d0;hb=2c94c3a5da9d6b4a0ac992386907d8a406ee38f7;hp=87edd57d05585ca8da37d9a14e15a2a6472e4cc5;hpb=a3c8691eb5bd772a43746fd5860d54a786463039;p=poolifier.git diff --git a/examples/multifunctionWorker.js b/examples/multifunctionWorker.js index 87edd57d..53217fa0 100644 --- a/examples/multifunctionWorker.js +++ b/examples/multifunctionWorker.js @@ -1,19 +1,14 @@ 'use strict' -const { ThreadWorker } = require('../lib/workers') +const { ThreadWorker } = require('poolifier') -function yourFunction (data) { - if (data.fname === 'fn0') { - console.log('Executing function 0') - return { data: '0 your input was' + data.input } - } else if (data.fname === 'fn1') { - console.log('Executing function 1') - return { data: '1 your input was' + data.input } - } +function fn0 (data) { + console.log('Executing function 0') + return { data: 'fn0 your input text was' + data.text } } -class MyWorker extends ThreadWorker { - constructor () { - super(yourFunction) - } +function fn1 (data) { + console.log('Executing function 1') + return { data: 'fn1 your input text was' + data.text } } -module.exports = new MyWorker() + +module.exports = new ThreadWorker({ fn0, fn1 })