File size: 375 Bytes
6491ad4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict'

const { parentPort } = require('worker_threads')
const { Writable } = require('stream')

function run () {
  parentPort.once('message', function ({ text, takeThisPortPlease }) {
    takeThisPortPlease.postMessage(`received: ${text}`)
  })
  return new Writable({
    autoDestroy: true,
    write (chunk, enc, cb) {
      cb()
    }
  })
}

module.exports = run