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(io): remove Deno.copy() #25345

Merged
merged 6 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
21 changes: 0 additions & 21 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1842,27 +1842,6 @@ declare namespace Deno {
seekSync(offset: number | bigint, whence: SeekMode): number;
}

/**
* Copies from `src` to `dst` until either EOF (`null`) is read from `src` or
* an error occurs. It resolves to the number of bytes copied or rejects with
* the first error encountered while copying.
*
* @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
*
* @param src The source to copy from
* @param dst The destination to copy to
* @param options Can be used to tune size of the buffer. Default size is 32kB
*/
export function copy(
src: Reader,
dst: Writer,
options?: { bufSize?: number },
): Promise<number>;

/**
* Turns a Reader, `r`, into an async iterator.
*
Expand Down
32 changes: 0 additions & 32 deletions ext/io/12_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,6 @@ const SeekMode = {
End: 2,
};

async function copy(
src,
dst,
options,
) {
internals.warnOnDeprecatedApi(
"Deno.copy()",
new Error().stack,
"Use `copy()` from `https://jsr.io/@std/io/doc/copy/~` instead.",
);
let n = 0;
const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE;
const b = new Uint8Array(bufSize);
let gotEOF = false;
while (gotEOF === false) {
const result = await src.read(b);
if (result === null) {
gotEOF = true;
} else {
let nwritten = 0;
while (nwritten < result) {
nwritten += await dst.write(
TypedArrayPrototypeSubarray(b, nwritten, result),
);
}
n += nwritten;
}
}
return n;
}

async function* iter(
r,
options,
Expand Down Expand Up @@ -337,7 +306,6 @@ const stdout = new Stdout();
const stderr = new Stderr();

export {
copy,
iter,
iterSync,
read,
Expand Down
2 changes: 0 additions & 2 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
delete globalThis.window;
delete Deno.Buffer;
delete Deno.close;
delete Deno.copy;
delete Deno.File;
delete Deno.fstat;
delete Deno.fstatSync;
Expand Down Expand Up @@ -1116,7 +1115,6 @@ function bootstrapWorkerRuntime(
if (future) {
delete Deno.Buffer;
delete Deno.close;
delete Deno.copy;
delete Deno.File;
delete Deno.fstat;
delete Deno.fstatSync;
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 @@ -48,7 +48,6 @@ util::unit_test_factory!(
image_data_test,
internals_test,
intl_test,
io_test,
jupyter_test,
kv_test,
kv_queue_test_no_db_close,
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,7 +1,6 @@
console.log("window is", globalThis.window);
console.log("Deno.Buffer is", Deno.Buffer);
console.log("Deno.close is", Deno.close);
console.log("Deno.copy is", Deno.copy);
console.log("Deno.File is", Deno.File);
console.log("Deno.fstat is", Deno.fstat);
console.log("Deno.fstatSync is", Deno.fstatSync);
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,7 +1,6 @@
window is undefined
Deno.Buffer is undefined
Deno.close is undefined
Deno.copy is undefined
Deno.File is undefined
Deno.fstat is undefined
Deno.fstatSync is undefined
Expand Down
80 changes: 0 additions & 80 deletions tests/unit/io_test.ts

This file was deleted.