Update pipe-ipc.js

This commit is contained in:
Namhyeon Go 2022-09-27 20:09:18 +09:00 committed by GitHub
parent c189a940e5
commit ee91c564dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,7 +46,6 @@ function PipeIPC() {
this._write = function(message) {
this.writer.Write(message);
this.writer.Write("\r\n");
};
this.write = function(message) {
@ -64,28 +63,7 @@ function PipeIPC() {
}
}
};
this._read = function() {
return this.reader.ReadAll().split(/\r?\n/);
};
this.read = function() {
var isRead = false;
var messages = [];
while (!isRead) {
try {
messages = this._read();
isRead = true;
} catch (e) {
this.closeReader();
this.createReader();
}
}
return messages;
};
this.flush = function() {
var isFlushed = false;
@ -101,8 +79,25 @@ function PipeIPC() {
}
};
this.readText = function() {
return this.read().join(' ');
this._read = function() {
return this.reader.ReadAll();
};
this.read = function() {
var isRead = false;
var text = "";
while (!isRead) {
try {
text += this._read();
isRead = true;
} catch (e) {
this.closeReader();
this.createReader();
}
}
return text;
};
this.close = function() {