From f052e66df538f7fabb0e173d9dd79888201286f2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 4 Dec 2022 02:53:04 -0800 Subject: Add some basic tests for process.stdout --- src/bun.js/builtins/js/ProcessObjectInternals.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/bun.js/builtins/js/ProcessObjectInternals.js') diff --git a/src/bun.js/builtins/js/ProcessObjectInternals.js b/src/bun.js/builtins/js/ProcessObjectInternals.js index 580152678..13c1da431 100644 --- a/src/bun.js/builtins/js/ProcessObjectInternals.js +++ b/src/bun.js/builtins/js/ProcessObjectInternals.js @@ -23,8 +23,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// @internal - function getStdioWriteStream(fd_, rawRequire) { var module = { path: "node:process", require: rawRequire }; var require = (path) => module.require(path); @@ -203,10 +201,10 @@ function getStdioWriteStream(fd_, rawRequire) { normalied === "utf8" || normalied === "utf-8" || normalied === "buffer" || - normalied === "binary" || - normalized === "" + normalied === "binary" ); } + var FastStdioWriteStream = class StdioWriteStream extends EventEmitter { #fd; #innerStream; @@ -258,6 +256,14 @@ function getStdioWriteStream(fd_, rawRequire) { return (this.#isTTY ??= require("node:tty").isatty(this.#fd)); } + ref() { + this.#getWriter().ref(); + } + + unref() { + this.#getWriter().unref(); + } + on(event, listener) { if (event === "close" || event === "finish") { this.#ensureInnerStream(); @@ -310,7 +316,7 @@ function getStdioWriteStream(fd_, rawRequire) { var writer = this.#getWriter(); const writeResult = writer.write(chunk); this.bytesWritten += writeResult; - const flushResult = writer.flush(); + const flushResult = writer.flush(false); return !!(writeResult || flushResult); } -- cgit v1.2.3