mirror of
https://github.com/denoland/deno.git
synced 2025-08-02 18:12:39 +00:00
Add buffer size argument to copy (#4907)
This commit is contained in:
parent
f7d1f82796
commit
26dfd3c110
4 changed files with 75 additions and 3 deletions
11
cli/js/io.ts
11
cli/js/io.ts
|
@ -70,9 +70,16 @@ export interface ReadWriteCloser extends Reader, Writer, Closer {}
|
|||
// https://golang.org/pkg/io/#ReadWriteSeeker
|
||||
export interface ReadWriteSeeker extends Reader, Writer, Seeker {}
|
||||
|
||||
export async function copy(src: Reader, dst: Writer): Promise<number> {
|
||||
export async function copy(
|
||||
src: Reader,
|
||||
dst: Writer,
|
||||
options?: {
|
||||
bufSize?: number;
|
||||
}
|
||||
): Promise<number> {
|
||||
let n = 0;
|
||||
const b = new Uint8Array(DEFAULT_BUFFER_SIZE);
|
||||
const bufSize = options?.bufSize ?? DEFAULT_BUFFER_SIZE;
|
||||
const b = new Uint8Array(bufSize);
|
||||
let gotEOF = false;
|
||||
while (gotEOF === false) {
|
||||
const result = await src.read(b);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue