From 62786cfebb5c9fe36d0930582951f442bdfe9441 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Thu, 25 Jan 2024 01:59:55 +1100 Subject: feat: deprecate `Deno.close()` (#22066) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For removal in Deno v2. --------- Co-authored-by: Bartek IwaƄczuk --- ext/node/polyfills/_fs/_fs_close.ts | 9 +++++++-- ext/node/polyfills/internal/fs/handle.ts | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'ext/node') diff --git a/ext/node/polyfills/_fs/_fs_close.ts b/ext/node/polyfills/_fs/_fs_close.ts index 9938668b3..fd01a0336 100644 --- a/ext/node/polyfills/_fs/_fs_close.ts +++ b/ext/node/polyfills/_fs/_fs_close.ts @@ -5,13 +5,16 @@ import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts"; import { getValidatedFd } from "ext:deno_node/internal/fs/utils.mjs"; +import { core } from "ext:core/mod.js"; export function close(fd: number, callback: CallbackWithError) { fd = getValidatedFd(fd); setTimeout(() => { let error = null; try { - Deno.close(fd); + // TODO(@littledivy): Treat `fd` as real file descriptor. `rid` is an + // implementation detail and may change. + core.close(fd); } catch (err) { error = err instanceof Error ? err : new Error("[non-error thrown]"); } @@ -21,5 +24,7 @@ export function close(fd: number, callback: CallbackWithError) { export function closeSync(fd: number) { fd = getValidatedFd(fd); - Deno.close(fd); + // TODO(@littledivy): Treat `fd` as real file descriptor. `rid` is an + // implementation detail and may change. + core.close(fd); } diff --git a/ext/node/polyfills/internal/fs/handle.ts b/ext/node/polyfills/internal/fs/handle.ts index b0097b424..ce218f24e 100644 --- a/ext/node/polyfills/internal/fs/handle.ts +++ b/ext/node/polyfills/internal/fs/handle.ts @@ -12,6 +12,7 @@ import { ReadOptions, TextOptionsArgument, } from "ext:deno_node/_fs/_fs_common.ts"; +import { core } from "ext:core/mod.js"; interface WriteResult { bytesWritten: number; @@ -134,7 +135,7 @@ export class FileHandle extends EventEmitter { close(): Promise { // Note that Deno.close is not async - return Promise.resolve(Deno.close(this.fd)); + return Promise.resolve(core.close(this.fd)); } } -- cgit v1.2.3