diff options
author | 2022-12-13 19:16:51 -0800 | |
---|---|---|
committer | 2022-12-13 19:16:51 -0800 | |
commit | 5516adec57d5cee29e636ca43b4155e6279c7e1d (patch) | |
tree | 5e50f88e229185055671acb5ab9adb3e941bdb0d /src/bun.js/builtins/js/ProcessObjectInternals.js | |
parent | 4e920d73b72e94d0974166a88f375a26cbc0618c (diff) | |
download | bun-5516adec57d5cee29e636ca43b4155e6279c7e1d.tar.gz bun-5516adec57d5cee29e636ca43b4155e6279c7e1d.tar.zst bun-5516adec57d5cee29e636ca43b4155e6279c7e1d.zip |
Avoid creating closure
Diffstat (limited to 'src/bun.js/builtins/js/ProcessObjectInternals.js')
-rw-r--r-- | src/bun.js/builtins/js/ProcessObjectInternals.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/bun.js/builtins/js/ProcessObjectInternals.js b/src/bun.js/builtins/js/ProcessObjectInternals.js index 5c5fab9ea..87bb07b95 100644 --- a/src/bun.js/builtins/js/ProcessObjectInternals.js +++ b/src/bun.js/builtins/js/ProcessObjectInternals.js @@ -534,20 +534,26 @@ function getStdinStream(fd, rawRequire, Bun) { } } - _read(size) { - this.#reader.read().then((data) => { - if (data.done) { + async #readInternal() { + try { + const { done, value } = await this.#reader.read(); + + if (!done) { + this.push(value); + } else { this.push(null); this.pause(); this.#readable = false; this.#onFinished(); - } else { - this.push(data.value); } - }).catch((err) => { + } catch (err) { this.#readable = false; this.#onFinished(err); - }); + } + } + + _read(size) { + this.#readInternal(); } #constructWriteStream() { |