From ea48bee3f7f08459c217ed5456e2ca1875ceb8d3 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 24 Jan 2024 15:09:56 +1100 Subject: [PATCH] feat: deprecate `Deno.seek()` and `Deno.seekSync()` (#22065) For removal in Deno v2. --- cli/tsc/dts/lib.deno.ns.d.ts | 6 ++++++ runtime/js/90_deno_ns.js | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 8759306dfe..cc069ed989 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -2100,6 +2100,9 @@ declare namespace Deno { * console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.End)); // "9" (i.e. 11-2) * ``` * + * @deprecated Use `file.seek()` instead. {@linkcode Deno.seek} will be + * removed in Deno 2.0. + * * @category I/O */ export function seek( @@ -2145,6 +2148,9 @@ declare namespace Deno { * console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.End)); // "9" (i.e. 11-2) * ``` * + * @deprecated Use `file.seekSync()` instead. {@linkcode Deno.seekSync} + * will be removed in Deno 2.0. + * * @category I/O */ export function seekSync( diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 452c62725d..24e73d30e7 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -109,8 +109,22 @@ const denoNs = { stdin: io.stdin, stdout: io.stdout, stderr: io.stderr, - seek: fs.seek, - seekSync: fs.seekSync, + seek(rid, offset, whence) { + internals.warnOnDeprecatedApi( + "Deno.seek()", + new Error().stack, + "Use `file.seek()` instead.", + ); + return fs.seek(rid, offset, whence); + }, + seekSync(rid, offset, whence) { + internals.warnOnDeprecatedApi( + "Deno.seekSync()", + new Error().stack, + "Use `file.seekSync()` instead.", + ); + return fs.seekSync(rid, offset, whence); + }, connect: net.connect, listen: net.listen, loadavg: os.loadavg,