X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultifunctionWorker.js;h=53217fa04957821ec4def7bca47b4334e21bf4d0;hb=31ce819c252a2aa74171548f48b0bd38e546c8f7;hp=8a1809ac7c25e81e3e9f697ce98a0b5748bd9c6f;hpb=60fbd6d6188b0902d157fd0cde04d6af3a391e32;p=poolifier.git diff --git a/examples/multifunctionWorker.js b/examples/multifunctionWorker.js index 8a1809ac..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.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 } } -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 })