Commit | Line | Data |
---|---|---|
506c2a14 | 1 | 'use strict' |
2 | const { ThreadWorker } = require('../lib/workers') | |
3 | const { isMainThread } = require('worker_threads') | |
4 | ||
5 | class MyWorker extends ThreadWorker { | |
6 | constructor () { | |
7 | super((data) => { | |
8 | for (let i = 0; i <= 100; i++) { | |
9 | const o = { | |
10 | a: i | |
11 | } | |
12 | JSON.stringify(o) | |
13 | } | |
14 | return isMainThread | |
15 | }, { maxInactiveTime: 1000 }) | |
16 | } | |
17 | } | |
18 | ||
19 | module.exports = new MyWorker() |