summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-04-25 00:09:14 +0200
committerGitHub <noreply@github.com>2020-04-25 00:09:14 +0200
commit0cb1bb98cc2de8dfe51b7adbe992666936146c90 (patch)
treea50b84ff268732e9db15895b443638ac86657007 /cli/js
parent833539fcafa77f341b74498b37372a61c5f10418 (diff)
BREAKING CHANGE: change order of args in Deno.copy() (#4885)
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/io.ts3
-rw-r--r--cli/js/lib.deno.ns.d.ts8
-rw-r--r--cli/js/tests/files_test.ts2
3 files changed, 6 insertions, 7 deletions
diff --git a/cli/js/io.ts b/cli/js/io.ts
index d41914d34..50ea1216a 100644
--- a/cli/js/io.ts
+++ b/cli/js/io.ts
@@ -70,8 +70,7 @@ export interface ReadWriteCloser extends Reader, Writer, Closer {}
// https://golang.org/pkg/io/#ReadWriteSeeker
export interface ReadWriteSeeker extends Reader, Writer, Seeker {}
-// https://golang.org/pkg/io/#Copy
-export async function copy(dst: Writer, src: Reader): Promise<number> {
+export async function copy(src: Reader, dst: Writer): Promise<number> {
let n = 0;
const b = new Uint8Array(DEFAULT_BUFFER_SIZE);
let gotEOF = false;
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index c40e42b8c..7145751c7 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -565,16 +565,16 @@ declare namespace Deno {
*
* const source = await Deno.open("my_file.txt");
* const buffer = new Deno.Buffer()
- * const bytesCopied1 = await Deno.copy(Deno.stdout, source);
- * const bytesCopied2 = await Deno.copy(buffer, source);
+ * const bytesCopied1 = await Deno.copy(source, Deno.stdout);
+ * const bytesCopied2 = await Deno.copy(source, buffer);
*
* Because `copy()` is defined to read from `src` until `EOF`, it does not
* treat an `EOF` from `read()` as an error to be reported.
*
- * @param dst The destination to copy to
* @param src The source to copy from
+ * @param dst The destination to copy to
*/
- export function copy(dst: Writer, src: Reader): Promise<number>;
+ export function copy(src: Reader, dst: Writer): Promise<number>;
/** Turns a Reader, `r`, into an async iterator.
*
diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts
index 1e2c06082..11a2e08ae 100644
--- a/cli/js/tests/files_test.ts
+++ b/cli/js/tests/files_test.ts
@@ -18,7 +18,7 @@ unitTest({ perms: { read: true } }, async function filesCopyToStdout(): Promise<
const filename = "cli/tests/fixture.json";
const file = await Deno.open(filename);
assert(file.rid > 2);
- const bytesWritten = await Deno.copy(Deno.stdout, file);
+ const bytesWritten = await Deno.copy(file, Deno.stdout);
const fileSize = Deno.statSync(filename).size;
assertEquals(bytesWritten, fileSize);
console.log("bytes written", bytesWritten);