diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-04-26 22:25:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 16:25:24 -0400 |
commit | 26dfd3c110ced12f2bd374de391c2c05e24290d8 (patch) | |
tree | 0e9ece1ff86d5565784a6d6f26b52e93a6c8371a /cli/js/io.ts | |
parent | f7d1f82796ac49c43d5a0075f86cfd8f83d83889 (diff) |
Add buffer size argument to copy (#4907)
Diffstat (limited to 'cli/js/io.ts')
-rw-r--r-- | cli/js/io.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cli/js/io.ts b/cli/js/io.ts index 50ea1216a..833d23874 100644 --- a/cli/js/io.ts +++ b/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); |