X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultifunctionWorker.js;h=53217fa04957821ec4def7bca47b4334e21bf4d0;hb=8f4878b72252b92146ae968357450df53cfa8fa7;hp=61369cfa57171d2cc26c5028cd170e4cd51cf9c7;hpb=5c5a1fb79906f18560012263239e7bd611ee8d2b;p=poolifier.git diff --git a/examples/multifunctionWorker.js b/examples/multifunctionWorker.js index 61369cfa..53217fa0 100644 --- a/examples/multifunctionWorker.js +++ b/examples/multifunctionWorker.js @@ -1,14 +1,14 @@ 'use strict' const { ThreadWorker } = require('poolifier') -function yourFunction (data) { - if (data.functionName === 'fn0') { - console.log('Executing function 0') - return { data: '0 your input was' + data.input } - } else if (data.functionName === '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 } } -module.exports = new ThreadWorker(yourFunction) +function fn1 (data) { + console.log('Executing function 1') + return { data: 'fn1 your input text was' + data.text } +} + +module.exports = new ThreadWorker({ fn0, fn1 })