diff options
author | 2022-12-05 03:52:20 -0800 | |
---|---|---|
committer | 2022-12-05 03:52:20 -0800 | |
commit | eeea1707a132ac7b5c8898f0b4bcf5c0f04a097b (patch) | |
tree | 55ed59416066e0ac9efcc2c53f5981cf988ae201 /src/bun.js/builtins/js | |
parent | b7e08cb9379634fa1a407f8aa84de78ae4839589 (diff) | |
download | bun-eeea1707a132ac7b5c8898f0b4bcf5c0f04a097b.tar.gz bun-eeea1707a132ac7b5c8898f0b4bcf5c0f04a097b.tar.zst bun-eeea1707a132ac7b5c8898f0b4bcf5c0f04a097b.zip |
`process.stdin` exists but doesn't totally work yet
Diffstat (limited to 'src/bun.js/builtins/js')
-rw-r--r-- | src/bun.js/builtins/js/ProcessObjectInternals.js | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/bun.js/builtins/js/ProcessObjectInternals.js b/src/bun.js/builtins/js/ProcessObjectInternals.js index 13c1da431..bf548eee6 100644 --- a/src/bun.js/builtins/js/ProcessObjectInternals.js +++ b/src/bun.js/builtins/js/ProcessObjectInternals.js @@ -464,7 +464,7 @@ function getStdinStream(fd, rawRequire, Bun) { constructor() { super({ readable: true, writable: true }); - this.#onReadable = this._read.bind(this); + this.#onReadable = (...args) => this._read(...args); } #onFinished(err) { @@ -522,11 +522,10 @@ function getStdinStream(fd, rawRequire, Bun) { Bun.stdin.stream(), )); - readStream.on("readable", () => { - const cb = this.#onReadable; - this.#onReadable = null; - cb(); + readStream.on("data", (data) => { + this.push(data); }); + readStream.ref(); readStream.on("end", () => { this.push(null); @@ -541,16 +540,14 @@ function getStdinStream(fd, rawRequire, Bun) { }); } - _read() { - var readStream = this.#readStream; - while (true) { - const buf = readStream.read(); - if (buf === null || !this.push(buf)) { - this.#onReadable = this._read.bind(this); - return; - } - } + ref() { + this.#readStream?.ref?.(); } + unref() { + this.#readStream?.unref?.(); + } + + _read(encoding, callback) {} #constructWriteStream() { var { createWriteStream } = require("node:fs"); @@ -598,7 +595,7 @@ function getStdinStream(fd, rawRequire, Bun) { _final(callback) { this.#writeStream.end(); - this.#onFinish = callback.bind(this); + this.#onFinish = (...args) => callback(...args); } }; |