summaryrefslogtreecommitdiff
path: root/cli/js/io.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/io.ts')
-rw-r--r--cli/js/io.ts11
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);