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

reorder copyN arguments to match Deno.copy (#4900)

This commit is contained in:
Akshat Agarwal 2020-04-27 01:56:02 +05:30 committed by GitHub
parent 26dfd3c110
commit 4f9bb11444
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 7 deletions

View file

@ -8,8 +8,8 @@ import { assert } from "../testing/asserts.ts";
* If read size is lesser than N, then returns nread
* */
export async function copyN(
dest: Writer,
r: Reader,
dest: Writer,
size: number
): Promise<number> {
let bytesRead = 0;

View file

@ -73,7 +73,7 @@ Deno.test(function testSliceLongToBytes2(): void {
Deno.test(async function testCopyN1(): Promise<void> {
const w = new Buffer();
const r = stringsReader("abcdefghij");
const n = await copyN(w, r, 3);
const n = await copyN(r, w, 3);
assertEquals(n, 3);
assertEquals(w.toString(), "abc");
});
@ -81,7 +81,7 @@ Deno.test(async function testCopyN1(): Promise<void> {
Deno.test(async function testCopyN2(): Promise<void> {
const w = new Buffer();
const r = stringsReader("abcdefghij");
const n = await copyN(w, r, 11);
const n = await copyN(r, w, 11);
assertEquals(n, 10);
assertEquals(w.toString(), "abcdefghij");
});

View file

@ -30,7 +30,7 @@ test(async function ioStringReader(): Promise<void> {
test(async function ioMultiReader(): Promise<void> {
const r = new MultiReader(new StringReader("abc"), new StringReader("def"));
const w = new StringWriter();
const n = await copyN(w, r, 4);
const n = await copyN(r, w, 4);
assertEquals(n, 4);
assertEquals(w.toString(), "abcd");
await copy(r, w);

View file

@ -7,7 +7,7 @@ import { copyN } from "./ioutil.ts";
test(async function ioStringWriter(): Promise<void> {
const w = new StringWriter("base");
const r = new StringReader("0123456789");
await copyN(w, r, 4);
await copyN(r, w, 4);
assertEquals(w.toString(), "base0123");
await copy(r, w);
assertEquals(w.toString(), "base0123456789");

View file

@ -297,7 +297,7 @@ export class MultipartReader {
buf.reset();
if (!p.fileName) {
// value
const n = await copyN(buf, p, maxValueBytes);
const n = await copyN(p, buf, maxValueBytes);
maxValueBytes -= n;
if (maxValueBytes < 0) {
throw new RangeError("message too large");
@ -320,8 +320,8 @@ export class MultipartReader {
});
try {
const size = await copyN(
file,
new MultiReader(buf, p),
file,
maxValueBytes
);
file.close();