From d2047f1337ccb5e27598308bf5fefa913eeaa34f Mon Sep 17 00:00:00 2001 From: nasa Date: Mon, 5 Jun 2023 21:43:04 +0900 Subject: 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 --- ext/node/polyfills/internal/fs/handle.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ext/node/polyfills/internal/fs/handle.ts') diff --git a/ext/node/polyfills/internal/fs/handle.ts b/ext/node/polyfills/internal/fs/handle.ts index a369a4a4d..a1ee263ea 100644 --- a/ext/node/polyfills/internal/fs/handle.ts +++ b/ext/node/polyfills/internal/fs/handle.ts @@ -24,6 +24,11 @@ export class FileHandle extends EventEmitter { ): Promise { return promises.readFile(this, opt); } + + close(): Promise { + // Note that Deno.close is not async + return Promise.resolve(Deno.close(this.fd)); + } } export default { -- cgit v1.2.3