1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00

feat(node_compat): Add a close method to the FileHandle class. (#19357)

## WHY 

ref: https://github.com/denoland/deno/issues/19165

The FileHandle class has many missing methods compared to node.
Add these.

## WHAT

- Add close method

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
nasa 2023-06-05 21:43:04 +09:00 committed by Bartek Iwańczuk
parent f35a119bc3
commit 4f7b109b93
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 6 additions and 1 deletions

View file

@ -16,5 +16,5 @@ Deno.test("readFileSuccess", async function () {
assert(data instanceof Uint8Array);
assertEquals(new TextDecoder().decode(data as Uint8Array), "hello world");
Deno.close(fileHandle.fd);
await fileHandle.close();
});

View file

@ -24,6 +24,11 @@ export class FileHandle extends EventEmitter {
): Promise<string | Buffer> {
return promises.readFile(this, opt);
}
close(): Promise<void> {
// Note that Deno.close is not async
return Promise.resolve(Deno.close(this.fd));
}
}
export default {