Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

BREAKING(buffer): remove Deno.Buffer #25441

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2651,81 +2651,6 @@ declare namespace Deno {
signal?: AbortSignal;
}

/**
* A variable-sized buffer of bytes with `read()` and `write()` methods.
*
* @deprecated This will be removed in Deno 2.0. See the
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
* for migration instructions.
*
* @category I/O
*/
export class Buffer implements Reader, ReaderSync, Writer, WriterSync {
constructor(ab?: ArrayBuffer);
/** Returns a slice holding the unread portion of the buffer.
*
* The slice is valid for use only until the next buffer modification (that
* is, only until the next call to a method like `read()`, `write()`,
* `reset()`, or `truncate()`). If `options.copy` is false the slice aliases the buffer content at
* least until the next buffer modification, so immediate changes to the
* slice will affect the result of future reads.
* @param options Defaults to `{ copy: true }`
*/
bytes(options?: { copy?: boolean }): Uint8Array;
/** Returns whether the unread portion of the buffer is empty. */
empty(): boolean;
/** A read only number of bytes of the unread portion of the buffer. */
readonly length: number;
/** The read only capacity of the buffer's underlying byte slice, that is,
* the total space allocated for the buffer's data. */
readonly capacity: number;
/** Discards all but the first `n` unread bytes from the buffer but
* continues to use the same allocated storage. It throws if `n` is
* negative or greater than the length of the buffer. */
truncate(n: number): void;
/** Resets the buffer to be empty, but it retains the underlying storage for
* use by future writes. `.reset()` is the same as `.truncate(0)`. */
reset(): void;
/** Reads the next `p.length` bytes from the buffer or until the buffer is
* drained. Returns the number of bytes read. If the buffer has no data to
* return, the return is EOF (`null`). */
readSync(p: Uint8Array): number | null;
/** Reads the next `p.length` bytes from the buffer or until the buffer is
* drained. Resolves to the number of bytes read. If the buffer has no
* data to return, resolves to EOF (`null`).
*
* NOTE: This methods reads bytes synchronously; it's provided for
* compatibility with `Reader` interfaces.
*/
read(p: Uint8Array): Promise<number | null>;
writeSync(p: Uint8Array): number;
/** NOTE: This methods writes bytes synchronously; it's provided for
* compatibility with `Writer` interface. */
write(p: Uint8Array): Promise<number>;
/** Grows the buffer's capacity, if necessary, to guarantee space for
* another `n` bytes. After `.grow(n)`, at least `n` bytes can be written to
* the buffer without another allocation. If `n` is negative, `.grow()` will
* throw. If the buffer can't grow it will throw an error.
*
* Based on Go Lang's
* [Buffer.Grow](https://golang.org/pkg/bytes/#Buffer.Grow). */
grow(n: number): void;
/** Reads data from `r` until EOF (`null`) and appends it to the buffer,
* growing the buffer as needed. It resolves to the number of bytes read.
* If the buffer becomes too large, `.readFrom()` will reject with an error.
*
* Based on Go Lang's
* [Buffer.ReadFrom](https://golang.org/pkg/bytes/#Buffer.ReadFrom). */
readFrom(r: Reader): Promise<number>;
/** Reads data from `r` until EOF (`null`) and appends it to the buffer,
* growing the buffer as needed. It returns the number of bytes read. If the
* buffer becomes too large, `.readFromSync()` will throw an error.
*
* Based on Go Lang's
* [Buffer.ReadFrom](https://golang.org/pkg/bytes/#Buffer.ReadFrom). */
readFromSync(r: ReaderSync): number;
}

/**
* Read Reader `r` until EOF (`null`) and resolve to the content as
* Uint8Array`.
Expand Down
237 changes: 0 additions & 237 deletions runtime/js/13_buffer.js

This file was deleted.

4 changes: 0 additions & 4 deletions runtime/js/90_deno_ns.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import * as errors from "ext:runtime/01_errors.js";
import * as version from "ext:runtime/01_version.ts";
import * as permissions from "ext:runtime/10_permissions.js";
import * as io from "ext:deno_io/12_io.js";
import * as buffer from "ext:runtime/13_buffer.js";
import * as fs from "ext:deno_fs/30_fs.js";
import * as os from "ext:runtime/30_os.js";
import * as fsEvents from "ext:runtime/40_fs_events.js";
Expand Down Expand Up @@ -82,9 +81,6 @@ const denoNs = {
env: os.env,
exit: os.exit,
execPath: os.execPath,
Buffer: buffer.Buffer,
readAll: buffer.readAll,
readAllSync: buffer.readAllSync,
copy: io.copy,
SeekMode: io.SeekMode,
File: fs.File,
Expand Down
3 changes: 0 additions & 3 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// deno-lint-ignore-file no-deprecated-deno-api
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

// Remove Intl.v8BreakIterator because it is a non-standard API.
Expand Down Expand Up @@ -800,7 +799,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
}
if (internals.future) {
delete globalThis.window;
delete Deno.Buffer;
delete Deno.FsFile.prototype.rid;
}
} else {
Expand Down Expand Up @@ -959,7 +957,6 @@ function bootstrapWorkerRuntime(
}

if (internals.future) {
delete Deno.Buffer;
delete Deno.FsFile.prototype.rid;
}
} else {
Expand Down
1 change: 0 additions & 1 deletion runtime/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ extension!(runtime,
"06_util.js",
"10_permissions.js",
"11_workers.js",
"13_buffer.js",
"30_os.js",
"40_fs_events.js",
"40_process.js",
Expand Down
1 change: 0 additions & 1 deletion tests/integration/js_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ util::unit_test_factory!(
blob_test,
body_test,
broadcast_channel_test,
buffer_test,
build_test,
cache_api_test,
chmod_test,
Expand Down
1 change: 0 additions & 1 deletion tests/specs/future/runtime_api/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
console.log("window is", globalThis.window);
console.log("Deno.Buffer is", Deno.Buffer);
console.log(
"Deno.FsFile.prototype.rid is",
Deno.openSync(import.meta.filename).rid,
Expand Down
1 change: 0 additions & 1 deletion tests/specs/future/runtime_api/main.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
window is undefined
Deno.Buffer is undefined
Deno.FsFile.prototype.rid is undefined
Deno.Listener.prototype.rid is undefined
Deno.Conn.prototype.rid is undefined
Expand Down
Loading