mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-20 23:08:46 +00:00
30 lines
540 B
JavaScript
30 lines
540 B
JavaScript
(function (stream, hooks) {
|
|
"use strict";
|
|
|
|
const { Writable, Readable } = stream;
|
|
|
|
function createStdin() {
|
|
return new Writable({
|
|
write(chunk, encoding, callback) {
|
|
hooks.stdinWrite(chunk, callback);
|
|
},
|
|
final(callback) {
|
|
hooks.stdinEnd(callback);
|
|
},
|
|
destroy(err, callback) {
|
|
hooks.stdinDestroy();
|
|
callback(err);
|
|
},
|
|
});
|
|
}
|
|
|
|
function createOutput() {
|
|
return new Readable({
|
|
read() {
|
|
// Output is pushed from the Go side as it arrives.
|
|
},
|
|
});
|
|
}
|
|
|
|
return { createStdin, createOutput };
|
|
}) |