From d42f1543121e7245789a96a485d1ef7645cb5fba Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 1 Nov 2023 20:26:12 +0100 Subject: feat: disposable Deno resources (#20845) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit implements Symbol.dispose and Symbol.asyncDispose for the relevant resources. Closes #20839 --------- Signed-off-by: Bartek Iwańczuk Co-authored-by: Bartek Iwańczuk --- ext/fs/30_fs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ext/fs') diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index d2a656a23..830703230 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -34,7 +34,7 @@ import { ReadableStreamPrototype, writableStreamForRid, } from "ext:deno_web/06_streams.js"; -import { pathFromURL } from "ext:deno_web/00_infra.js"; +import { pathFromURL, SymbolDispose } from "ext:deno_web/00_infra.js"; function chmodSync(path, mode) { ops.op_fs_chmod_sync(pathFromURL(path), mode); @@ -669,6 +669,10 @@ class FsFile { } return this.#writable; } + + [SymbolDispose]() { + core.tryClose(this.rid); + } } function checkOpenOptions(options) { -- cgit v1.2.3