mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
Increase copyN buffer size to match go implementation (#4904)
This commit is contained in:
parent
49cad79fb1
commit
128dce0d8a
1 changed files with 4 additions and 2 deletions
|
@ -4,6 +4,8 @@ type Reader = Deno.Reader;
|
|||
type Writer = Deno.Writer;
|
||||
import { assert } from "../testing/asserts.ts";
|
||||
|
||||
const DEFAULT_BUFFER_SIZE = 32 * 1024;
|
||||
|
||||
/** copy N size at the most.
|
||||
* If read size is lesser than N, then returns nread
|
||||
* */
|
||||
|
@ -13,9 +15,9 @@ export async function copyN(
|
|||
size: number
|
||||
): Promise<number> {
|
||||
let bytesRead = 0;
|
||||
let buf = new Uint8Array(1024);
|
||||
let buf = new Uint8Array(DEFAULT_BUFFER_SIZE);
|
||||
while (bytesRead < size) {
|
||||
if (size - bytesRead < 1024) {
|
||||
if (size - bytesRead < DEFAULT_BUFFER_SIZE) {
|
||||
buf = new Uint8Array(size - bytesRead);
|
||||
}
|
||||
const result = await r.read(buf);
|
||||
|
|
Loading…
Reference in a new issue