From 6fb0cfe8896e6f4efd7650b27e486be5db0a7ccf Mon Sep 17 00:00:00 2001 From: Moon Man Date: Tue, 30 Jan 2024 02:38:17 -0500 Subject: [PATCH] simplify --- dist/main.d.ts | 2 -- dist/main.js | 8 ++------ src/main.ts | 8 ++------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/dist/main.d.ts b/dist/main.d.ts index 81dd16a..5d5a9d1 100644 --- a/dist/main.d.ts +++ b/dist/main.d.ts @@ -7,8 +7,6 @@ type ServerHandlerCallback = (reply: "reply" | "noreply", ...extraArgs: any[]) = type ServerHandler = (term: any, from: any, state: any, callback: ServerHandlerCallback) => void; export declare class Port extends Duplex { readonly bert: Bert; - private originalStdout; - private readonly fakeStdout; constructor(allBinariesAsString?: boolean, mapKeyAsAtom?: boolean, decodeUndefinedValues?: boolean); _read(): any; _write(obj: any, encodingOrCallback?: BufferEncoding | WriteCallback, callback?: WriteCallback | undefined): boolean; diff --git a/dist/main.js b/dist/main.js index f69218e..7fbf445 100644 --- a/dist/main.js +++ b/dist/main.js @@ -3,13 +3,9 @@ import { Duplex } from "node:stream"; const log = (msg) => process.stderr.write(`${msg}\r\n`); export class Port extends Duplex { bert; - originalStdout; - fakeStdout = () => true; constructor(allBinariesAsString, mapKeyAsAtom, decodeUndefinedValues) { super({ objectMode: true }); this.bert = new Bert(allBinariesAsString, mapKeyAsAtom, decodeUndefinedValues); - this.originalStdout = process.stdout; - process.stdout.write = this.fakeStdout; process.stdin.on("readable", () => { while (this._read()) { } }); @@ -39,8 +35,8 @@ export class Port extends Duplex { const term = this.bert.encode(obj, true); const len = Buffer.alloc(4); len.writeUInt32BE(term.length, 0); - this.originalStdout.write(len); - this.originalStdout.write(term, actualCallback); + process.stdout.write(len); + process.stdout.write(term, actualCallback); return true; } catch (error) { diff --git a/src/main.ts b/src/main.ts index c18c646..5215055 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,14 +10,10 @@ const log = (msg: string) => process.stderr.write(`${msg}\r\n`); export class Port extends Duplex { public readonly bert: Bert; - private originalStdout; - private readonly fakeStdout = () => true; constructor(allBinariesAsString?: boolean, mapKeyAsAtom?: boolean, decodeUndefinedValues?: boolean) { super({ objectMode: true }); this.bert = new Bert(allBinariesAsString, mapKeyAsAtom, decodeUndefinedValues); - this.originalStdout = process.stdout; - process.stdout.write = this.fakeStdout; process.stdin.on("readable", () => { while (this._read()) { } }); @@ -51,8 +47,8 @@ export class Port extends Duplex { const len = Buffer.alloc(4); len.writeUInt32BE(term.length, 0); - this.originalStdout.write(len); - this.originalStdout.write(term, actualCallback); + process.stdout.write(len); + process.stdout.write(term, actualCallback); return true; } catch (error) {