aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/fs.exports.js44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/bun.js/fs.exports.js b/src/bun.js/fs.exports.js
index 019a98d6f..ebf929cb1 100644
--- a/src/bun.js/fs.exports.js
+++ b/src/bun.js/fs.exports.js
@@ -339,7 +339,6 @@ function getLazyReadStream() {
callback();
return;
}
- // this[readStreamPathFastPathSymbol] = false;
var { path, flags, mode } = this;
this.#fs.open(path, flags, mode, (er, fd) => {
@@ -625,7 +624,7 @@ function getLazyWriteStream() {
this._writableState.autoDestroy = val;
}
- destroySoon = this.end;
+ destroySoon = this.end; // TODO: what is this for?
// noop, node has deprecated this
open() {}
@@ -696,6 +695,26 @@ function getLazyWriteStream() {
});
}
+ _construct(callback) {
+ if (typeof this.fd === "number") {
+ callback();
+ return;
+ }
+ var { path, flags, mode } = this;
+
+ this.#fs.open(path, flags, mode, (er, fd) => {
+ if (er) {
+ callback(er);
+ return;
+ }
+
+ this.fd = fd;
+ callback();
+ this.emit("open", this.fd);
+ this.emit("ready");
+ });
+ }
+
_destroy(err, cb) {
if (this.fd === null) {
return cb(err);
@@ -745,7 +764,7 @@ function getLazyWriteStream() {
chunk.length,
this.pos,
(err, bytes) => {
- ths[kIoDone] = false;
+ this[kIoDone] = false;
this.#handleWrite(err, bytes);
this.emit(kIoDone);
@@ -754,12 +773,19 @@ function getLazyWriteStream() {
);
} else {
this[kIoDone] = true;
- this.#fs.write(this.fd, chunk, 0, chunk.length, null, (err, bytes) => {
- ths[kIoDone] = false;
- this.#handleWrite(err, bytes);
- this.emit(kIoDone);
- !err ? cb() : cb(err);
- });
+ this.#fs.write(
+ this.fd,
+ chunk,
+ 0,
+ chunk.length,
+ null,
+ (err, bytes, buffer) => {
+ this[kIoDone] = false;
+ this.#handleWrite(err, bytes);
+ this.emit(kIoDone);
+ !err ? cb() : cb(err);
+ }
+ );
}
}
_write = this.#internalWrite;