Fix method scope
[poolifier.git] / examples / yourWorker.js
... / ...
CommitLineData
1'use strict'
2const { ThreadWorker } = require('poolifier')
3const { isMainThread } = require('worker_threads')
4
5const debug = false
6
7function yourFunction () {
8 for (let i = 0; i <= 1000; i++) {
9 const o = {
10 a: i
11 }
12 JSON.stringify(o)
13 }
14 debug === true && console.log('This is the main thread ' + isMainThread)
15 return { ok: 1 }
16}
17
18module.exports = new ThreadWorker(yourFunction)