Files
infocom-systems-design/node_modules/thread-stream/test/on-message.js
2025-10-03 22:27:28 +03:00

19 lines
375 B
JavaScript

'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