diff --git a/src/file.ts b/src/file.ts index 19e4297c..d82d1397 100644 --- a/src/file.ts +++ b/src/file.ts @@ -166,12 +166,12 @@ export abstract class File { public abstract close(): Promise; public abstract closeSync(): void; - public [Symbol.asyncDispose](): Promise { - return this.close(); + public async [Symbol.asyncDispose](): Promise { + await this.close(); } public [Symbol.dispose](): void { - return this.closeSync(); + this.closeSync(); } public abstract truncate(len: number): Promise; @@ -427,12 +427,12 @@ export class PreloadFile extends File { if (length > this._buffer.length) { const data = new Uint8Array(length - this._buffer.length); // Write will set stats.size and handle syncing. - this.writeSync(data, 0, data.length, this._buffer.length); + this._write(data, 0, data.length, this._buffer.length); return; } this.stats.size = length; // Truncate. - this._buffer = this._buffer.slice(0, length); + this._buffer = length ? this._buffer.slice(0, length) : new Uint8Array(); } public async truncate(length: number): Promise { @@ -641,14 +641,6 @@ export class PreloadFile extends File { this.stats.mode = (this.stats.mode & ~S_IFMT) | type; this.syncSync(); } - - public async [Symbol.asyncDispose]() { - await this.close(); - } - - public [Symbol.dispose]() { - this.closeSync(); - } } /**