Update pipe-ipc.js

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

View File

@ -25,9 +25,9 @@ function PipeIPC() {
} }
}; };
this.createWriter = function() { this.createWriter = function(iomode) {
//this.writer = CreateObject("Scripting.FileSystemObject").CreateTextFile(this.path, true, true); //this.writer = CreateObject("Scripting.FileSystemObject").CreateTextFile(this.path, true, true);
this.writer = CreateObject("Scripting.FileSystemObject").OpenTextFile(this.path, ForAppending, true, TristateTrue); this.writer = CreateObject("Scripting.FileSystemObject").OpenTextFile(this.path, iomode, true, TristateTrue);
}; };
this.closeWriter = function() { this.closeWriter = function() {
@ -54,7 +54,8 @@ function PipeIPC() {
while (!isWritten) { while (!isWritten) {
try { try {
this.createWriter(); this.flush();
this.createWriter(ForAppending);
this._write(message); this._write(message);
this.writer.Close(); this.writer.Close();
isWritten = true; isWritten = true;
@ -85,6 +86,21 @@ function PipeIPC() {
return messages; return messages;
}; };
this.flush = function() {
var isFlushed = false;
while (!isFlushed) {
try {
this.createWriter(ForWriting);
this._write("");
this.writer.Close();
isFlushed = true;
} catch (e) {
isFlushed = false;
}
}
};
this.readText = function() { this.readText = function() {
return this.read().join(' '); return this.read().join(' ');
}; };
@ -99,7 +115,7 @@ exports.create = function() {
return new PipeIPC(); return new PipeIPC();
}; };
exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.1"; exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.2";
exports.AUTHOR = "Nathan Catswords <catswords@protonmail.com>"; exports.AUTHOR = "Nathan Catswords <catswords@protonmail.com>";
exports.global = global; exports.global = global;
exports.require = require; exports.require = require;