X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultifunctionWorker.js;h=53217fa04957821ec4def7bca47b4334e21bf4d0;hb=0682ba158c6af9ffc453f38bd7d16438eab97695;hp=f3efb4529e337945ad17e0734ede160c7c7d2cd7;hpb=1f9a5a440caea7dc60a664d413304250969bb4d8;p=poolifier.git diff --git a/examples/multifunctionWorker.js b/examples/multifunctionWorker.js index f3efb452..53217fa0 100644 --- a/examples/multifunctionWorker.js +++ b/examples/multifunctionWorker.js @@ -1,14 +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 } } -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 })