From 064a6c048ab420302cbb822bedd3fc365b4259a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 24 Jan 2024 14:57:54 +0100 Subject: feat: Add warnings for more deprecated APIs (#21992) Follow up to https://github.com/denoland/deno/pull/21939 that adds deprecation warnings to more `Deno` APIs: - `Deno.copy()` - `Deno.iter()` - `Deno.iterSync()` - `new Deno.Buffer()` - `Deno.readAll()` - `Deno.readAllSync()` - `Deno.writeAll()` - `Deno.writeAllSync()` - `Deno.FsWatcher.return` - `Deno.serveHttp()` - `Deno.metrics()` --------- Signed-off-by: Asher Gomez Co-authored-by: Asher Gomez --- ext/io/12_io.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/io/12_io.js b/ext/io/12_io.js index 9f4a3766b..2a0d589a7 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -3,8 +3,7 @@ // Interfaces 100% copied from Go. // Documentation liberally lifted from them too. // Thank you! We love Go! <3 - -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { op_stdin_set_raw, op_is_terminal, @@ -40,6 +39,11 @@ async function copy( dst, options, ) { + internals.warnOnDeprecatedApi( + "Deno.copy()", + new Error().stack, + "Use `copy()` from `https://deno.land/std/io/copy.ts` instead.", + ); let n = 0; const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE; const b = new Uint8Array(bufSize); @@ -65,6 +69,11 @@ async function* iter( r, options, ) { + internals.warnOnDeprecatedApi( + "Deno.iter()", + new Error().stack, + "Use `ReadableStream` instead.", + ); const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE; const b = new Uint8Array(bufSize); while (true) { @@ -81,6 +90,11 @@ function* iterSync( r, options, ) { + internals.warnOnDeprecatedApi( + "Deno.iterSync()", + new Error().stack, + "Use `ReadableStream` instead.", + ); const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE; const b = new Uint8Array(bufSize); while (true) { -- cgit v1.2.3