summaryrefslogtreecommitdiff
path: root/runtime/js/13_buffer.js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js/13_buffer.js')
-rw-r--r--runtime/js/13_buffer.js27
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));