diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-01-24 14:57:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 14:57:54 +0100 |
commit | 064a6c048ab420302cbb822bedd3fc365b4259a7 (patch) | |
tree | 1aa6ee2716f2cc30e74dd97818330a5e2d154a07 /runtime/js/13_buffer.js | |
parent | 745333f073aba4c97e7d06c731063105493cde5a (diff) |
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 <ashersaupingomez@gmail.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Diffstat (limited to 'runtime/js/13_buffer.js')
-rw-r--r-- | runtime/js/13_buffer.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/runtime/js/13_buffer.js b/runtime/js/13_buffer.js index 36d979e75..cac1a6694 100644 --- a/runtime/js/13_buffer.js +++ b/runtime/js/13_buffer.js @@ -4,7 +4,7 @@ // Copyright 2009 The Go Authors. All rights reserved. BSD license. // https://github.com/golang/go/blob/master/LICENSE -import { primordials } from "ext:core/mod.js"; +import { internals, primordials } from "ext:core/mod.js"; const { ArrayBufferPrototypeGetByteLength, TypedArrayPrototypeSubarray, @@ -45,6 +45,11 @@ class Buffer { #off = 0; // read at buf[off], write at buf[buf.byteLength] constructor(ab) { + internals.warnOnDeprecatedApi( + "new Deno.Buffer()", + new Error().stack, + "Use `Buffer` from `https://deno.land/std/io/buffer.ts` instead.", + ); if (ab == null) { this.#buf = new Uint8Array(0); return; @@ -230,18 +235,33 @@ class Buffer { } async function readAll(r) { + internals.warnOnDeprecatedApi( + "Deno.readAll()", + new Error().stack, + "Use `readAll()` from `https://deno.land/std/io/read_all.ts` instead.", + ); const buf = new Buffer(); await buf.readFrom(r); return buf.bytes(); } function readAllSync(r) { + internals.warnOnDeprecatedApi( + "Deno.readAllSync()", + new Error().stack, + "Use `readAllSync()` from `https://deno.land/std/io/read_all.ts` instead.", + ); const buf = new Buffer(); buf.readFromSync(r); return buf.bytes(); } async function writeAll(w, arr) { + internals.warnOnDeprecatedApi( + "Deno.writeAll()", + new Error().stack, + "Use `writeAll()` from `https://deno.land/std/io/write_all.ts` instead.", + ); let nwritten = 0; while (nwritten < arr.length) { nwritten += await w.write(TypedArrayPrototypeSubarray(arr, nwritten)); @@ -249,6 +269,11 @@ async function writeAll(w, arr) { } function writeAllSync(w, arr) { + internals.warnOnDeprecatedApi( + "Deno.writeAllSync()", + new Error().stack, + "Use `writeAllSync()` from `https://deno.land/std/io/write_all.ts` instead.", + ); let nwritten = 0; while (nwritten < arr.length) { nwritten += w.writeSync(TypedArrayPrototypeSubarray(arr, nwritten)); |