1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

BREAKING(io): remove Deno.read[Sync]() (#25409)

Towards #22079

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Asher Gomez 2024-09-04 19:34:40 +10:00 committed by GitHub
parent b333dccee8
commit 31ecc09b5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1 additions and 90 deletions

View file

@ -46,8 +46,7 @@ Deno.bench("b64_rt_short", { n: 1e6 }, () => {
const buf = new Uint8Array(100); const buf = new Uint8Array(100);
const file = Deno.openSync("/dev/zero"); const file = Deno.openSync("/dev/zero");
Deno.bench("read_zero", { n: 5e5 }, () => { Deno.bench("read_zero", { n: 5e5 }, () => {
// deno-lint-ignore no-deprecated-deno-api file.readSync(buf);
Deno.readSync(file.rid, buf);
}); });
} }

View file

@ -1920,70 +1920,6 @@ declare namespace Deno {
*/ */
export function createSync(path: string | URL): FsFile; export function createSync(path: string | URL): FsFile;
/** Read from a resource ID (`rid`) into an array buffer (`buffer`).
*
* Resolves to either the number of bytes read during the operation or EOF
* (`null`) if there was nothing more to read.
*
* It is possible for a read to successfully return with `0` bytes. This does
* not indicate EOF.
*
* This function is one of the lowest level APIs and most users should not
* work with this directly, but rather use {@linkcode ReadableStream} and
* {@linkcode https://jsr.io/@std/streams/doc/to-array-buffer/~/toArrayBuffer | toArrayBuffer}
* instead.
*
* **It is not guaranteed that the full buffer will be read in a single call.**
*
* ```ts
* // if "/foo/bar.txt" contains the text "hello world":
* using file = await Deno.open("/foo/bar.txt");
* const buf = new Uint8Array(100);
* const numberOfBytesRead = await Deno.read(file.rid, buf); // 11 bytes
* const text = new TextDecoder().decode(buf); // "hello world"
* ```
*
* @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 function read(rid: number, buffer: Uint8Array): Promise<number | null>;
/** Synchronously read from a resource ID (`rid`) into an array buffer
* (`buffer`).
*
* Returns either the number of bytes read during the operation or EOF
* (`null`) if there was nothing more to read.
*
* It is possible for a read to successfully return with `0` bytes. This does
* not indicate EOF.
*
* This function is one of the lowest level APIs and most users should not
* work with this directly, but rather use {@linkcode ReadableStream} and
* {@linkcode https://jsr.io/@std/streams/doc/to-array-buffer/~/toArrayBuffer | toArrayBuffer}
* instead.
*
* **It is not guaranteed that the full buffer will be read in a single
* call.**
*
* ```ts
* // if "/foo/bar.txt" contains the text "hello world":
* using file = Deno.openSync("/foo/bar.txt");
* const buf = new Uint8Array(100);
* const numberOfBytesRead = Deno.readSync(file.rid, buf); // 11 bytes
* const text = new TextDecoder().decode(buf); // "hello world"
* ```
*
* @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 function readSync(rid: number, buffer: Uint8Array): number | null;
/** Seek a resource ID (`rid`) to the given `offset` under mode given by `whence`. /** Seek a resource ID (`rid`) to the given `offset` under mode given by `whence`.
* The call resolves to the new position within the resource (bytes from the start). * The call resolves to the new position within the resource (bytes from the start).
* *

View file

@ -87,22 +87,6 @@ const denoNs = {
readAllSync: buffer.readAllSync, readAllSync: buffer.readAllSync,
copy: io.copy, copy: io.copy,
SeekMode: io.SeekMode, SeekMode: io.SeekMode,
read(rid, buffer) {
internals.warnOnDeprecatedApi(
"Deno.read()",
new Error().stack,
"Use `reader.read()` instead.",
);
return io.read(rid, buffer);
},
readSync(rid, buffer) {
internals.warnOnDeprecatedApi(
"Deno.readSync()",
new Error().stack,
"Use `reader.readSync()` instead.",
);
return io.readSync(rid, buffer);
},
File: fs.File, File: fs.File,
FsFile: fs.FsFile, FsFile: fs.FsFile,
open: fs.open, open: fs.open,

View file

@ -805,8 +805,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
delete Deno.FsFile.prototype.rid; delete Deno.FsFile.prototype.rid;
delete Deno.funlock; delete Deno.funlock;
delete Deno.funlockSync; delete Deno.funlockSync;
delete Deno.read;
delete Deno.readSync;
delete Deno.seek; delete Deno.seek;
delete Deno.seekSync; delete Deno.seekSync;
} }
@ -972,8 +970,6 @@ function bootstrapWorkerRuntime(
delete Deno.FsFile.prototype.rid; delete Deno.FsFile.prototype.rid;
delete Deno.funlock; delete Deno.funlock;
delete Deno.funlockSync; delete Deno.funlockSync;
delete Deno.read;
delete Deno.readSync;
delete Deno.seek; delete Deno.seek;
delete Deno.seekSync; delete Deno.seekSync;
} }

View file

@ -7,8 +7,6 @@ console.log(
); );
console.log("Deno.funlock is", Deno.funlock); console.log("Deno.funlock is", Deno.funlock);
console.log("Deno.funlockSync is", Deno.funlockSync); console.log("Deno.funlockSync is", Deno.funlockSync);
console.log("Deno.read is", Deno.read);
console.log("Deno.readSync is", Deno.readSync);
console.log("Deno.seek is", Deno.seek); console.log("Deno.seek is", Deno.seek);
console.log("Deno.seekSync is", Deno.seekSync); console.log("Deno.seekSync is", Deno.seekSync);

View file

@ -4,8 +4,6 @@ Deno.File is undefined
Deno.FsFile.prototype.rid is undefined Deno.FsFile.prototype.rid is undefined
Deno.funlock is undefined Deno.funlock is undefined
Deno.funlockSync is undefined Deno.funlockSync is undefined
Deno.read is undefined
Deno.readSync is undefined
Deno.seek is undefined Deno.seek is undefined
Deno.seekSync is undefined Deno.seekSync is undefined
Deno.Listener.prototype.rid is undefined Deno.Listener.prototype.rid is undefined