diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-25 01:59:55 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 15:59:55 +0100 |
commit | 62786cfebb5c9fe36d0930582951f442bdfe9441 (patch) | |
tree | a1bede5492a5b1bf4a202ee8994df027f098e788 /ext/node | |
parent | 4af121687cb4c26f4a2f3e4ad266490d8faa3d2d (diff) |
feat: deprecate `Deno.close()` (#22066)
For removal in Deno v2.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/polyfills/_fs/_fs_close.ts | 9 | ||||
-rw-r--r-- | ext/node/polyfills/internal/fs/handle.ts | 3 |
2 files changed, 9 insertions, 3 deletions
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<void> { // Note that Deno.close is not async - return Promise.resolve(Deno.close(this.fd)); + return Promise.resolve(core.close(this.fd)); } } |