chore: deprecate Deno.Buffer and read/write utils (#9793)

This commit marks the `Deno.Buffer` / `Deno.readAll` /
`Deno.readAllSync` / `Deno.writeAll` / `Deno.writeAllSync` utils as
deprecated, and schedules them for removal in Deno 2.0. These
utilities are implemented in pure JS, so should not be part of the
Deno namespace.

These utilities are now available in std/io/buffer and std/io/util:
https://github.com/denoland/deno_std/pull/808.

This additionallty removes all internal dependance on Deno.Buffer.
This commit is contained in:
Luca Casonato 2021-04-06 00:05:36 +02:00 committed by GitHub
parent 2aed322dd5
commit da60e2afcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 21 deletions

View file

@ -1,5 +1,6 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import { assertEquals, unitTest } from "./test_util.ts";
import { Buffer } from "../../../test_util/std/io/buffer.ts";
const DEFAULT_BUF_SIZE = 32 * 1024;
@ -12,7 +13,7 @@ function repeat(c: string, bytes: number): Uint8Array {
return ui8;
}
function spyRead(obj: Deno.Buffer): Spy {
function spyRead(obj: Buffer): Spy {
const spy: Spy = {
calls: 0,
};
@ -29,8 +30,8 @@ function spyRead(obj: Deno.Buffer): Spy {
unitTest(async function copyWithDefaultBufferSize() {
const xBytes = repeat("b", DEFAULT_BUF_SIZE);
const reader = new Deno.Buffer(xBytes.buffer as ArrayBuffer);
const write = new Deno.Buffer();
const reader = new Buffer(xBytes.buffer as ArrayBuffer);
const write = new Buffer();
const readSpy = spyRead(reader);
@ -44,8 +45,8 @@ unitTest(async function copyWithDefaultBufferSize() {
unitTest(async function copyWithCustomBufferSize() {
const bufSize = 1024;
const xBytes = repeat("b", DEFAULT_BUF_SIZE);
const reader = new Deno.Buffer(xBytes.buffer as ArrayBuffer);
const write = new Deno.Buffer();
const reader = new Buffer(xBytes.buffer as ArrayBuffer);
const write = new Buffer();
const readSpy = spyRead(reader);
@ -61,7 +62,7 @@ unitTest({ perms: { write: true } }, async function copyBufferToFile() {
// bigger than max File possible buffer 16kb
const bufSize = 32 * 1024;
const xBytes = repeat("b", bufSize);
const reader = new Deno.Buffer(xBytes.buffer as ArrayBuffer);
const reader = new Buffer(xBytes.buffer as ArrayBuffer);
const write = await Deno.open(filePath, { write: true, create: true });
const n = await Deno.copy(reader, write, { bufSize });