diff options
author | 2022-12-04 02:53:04 -0800 | |
---|---|---|
committer | 2022-12-04 02:53:04 -0800 | |
commit | f052e66df538f7fabb0e173d9dd79888201286f2 (patch) | |
tree | 336fec084318b8cb93f48b85185c662d7e5b226b /src/bun.js/builtins/js/ProcessObjectInternals.js | |
parent | 46e34a3fa9cba38e70ba034e5ea45584ecce5960 (diff) | |
download | bun-f052e66df538f7fabb0e173d9dd79888201286f2.tar.gz bun-f052e66df538f7fabb0e173d9dd79888201286f2.tar.zst bun-f052e66df538f7fabb0e173d9dd79888201286f2.zip |
Add some basic tests for process.stdout
Diffstat (limited to 'src/bun.js/builtins/js/ProcessObjectInternals.js')
-rw-r--r-- | src/bun.js/builtins/js/ProcessObjectInternals.js | 16 |
1 files changed, 11 insertions, 5 deletions
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); } |