maybe works now?

This commit is contained in:
Moon Man 2024-01-28 10:12:30 -05:00
parent f5f2341218
commit a7535f4392
3 changed files with 6 additions and 17 deletions

5
dist/main.d.ts vendored
View File

@ -4,8 +4,7 @@ import { Duplex } from "node:stream";
type WriteCallback = (error: Error | null | undefined) => void;
export declare class Port extends Duplex {
constructor();
read(): any;
write(obj: any, encodingOrCallback?: BufferEncoding | WriteCallback, callback?: WriteCallback | undefined): boolean;
_final(): void;
_read(): any;
_write(obj: any, encodingOrCallback?: BufferEncoding | WriteCallback, callback?: WriteCallback | undefined): boolean;
}
export {};

8
dist/main.js vendored
View File

@ -7,7 +7,7 @@ export class Port extends Duplex {
constructor() {
super({ objectMode: true });
}
read() {
_read() {
const lenBytes = process.stdin.read(4);
if (lenBytes) {
const termLen = bert.bytesToInt(lenBytes, 4, true);
@ -23,7 +23,7 @@ export class Port extends Duplex {
else
return null;
}
write(obj, encodingOrCallback, callback) {
_write(obj, encodingOrCallback, callback) {
const actualCallback = callback || typeof encodingOrCallback === "function" ? encodingOrCallback : undefined;
try {
const term = bert.encode(obj, true);
@ -37,8 +37,4 @@ export class Port extends Duplex {
return false;
}
}
// When all the data is done passing, it stops.
_final() {
this.push(null);
}
}

View File

@ -13,7 +13,7 @@ export class Port extends Duplex {
super({ objectMode: true });
}
read() {
_read() {
const lenBytes = process.stdin.read(4);
if (lenBytes) {
const termLen = bert.bytesToInt(lenBytes, 4, true);
@ -30,7 +30,7 @@ export class Port extends Duplex {
else return null;
}
write(obj: any, encodingOrCallback?: BufferEncoding | WriteCallback, callback?: WriteCallback | undefined) {
_write(obj: any, encodingOrCallback?: BufferEncoding | WriteCallback, callback?: WriteCallback | undefined) {
const actualCallback: any = callback || typeof encodingOrCallback === "function" ? encodingOrCallback : undefined;
try {
@ -46,10 +46,4 @@ export class Port extends Duplex {
return false;
}
}
// When all the data is done passing, it stops.
_final() {
this.push(null);
}
}