diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-04-29 12:25:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 12:25:40 +0200 |
commit | ec41fb69ccabf012a6368a8df5166578e5ee2307 (patch) | |
tree | 0d831679583cb9ddd3fface2a4c2f4ba9025bf6e /std/io/ioutil.ts | |
parent | 0703431ec23efbde59669cc0568ec740909e47d7 (diff) |
fix: Make std/io copyN write the whole read buffer (#4978)
Diffstat (limited to 'std/io/ioutil.ts')
-rw-r--r-- | std/io/ioutil.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/std/io/ioutil.ts b/std/io/ioutil.ts index 7b6761708..c7b92fc1d 100644 --- a/std/io/ioutil.ts +++ b/std/io/ioutil.ts @@ -24,7 +24,10 @@ export async function copyN( const nread = result ?? 0; bytesRead += nread; if (nread > 0) { - const n = await dest.write(buf.slice(0, nread)); + let n = 0; + while (n < nread) { + n += await dest.write(buf.slice(n, nread)); + } assert(n === nread, "could not write"); } if (result === null) { |