refactor: move javascript examples in their own folder
[poolifier.git] / examples / javascript / yourWorker.js
CommitLineData
27006a3d 1'use strict'
fd7ebd49 2const { isMainThread } = require('worker_threads')
65d7a1c9 3const { ThreadWorker } = require('poolifier')
fd7ebd49
JB
4
5const debug = false
27006a3d 6
7a6a0a96 7function yourFunction () {
106744f7 8 for (let i = 0; i <= 1000; i++) {
9 const o = {
10 a: i
11 }
12 JSON.stringify(o)
13 }
53795b86 14 debug === true && console.info('This is the main thread ' + isMainThread)
106744f7 15 return { ok: 1 }
16}
17
1f9a5a44 18module.exports = new ThreadWorker(yourFunction)