diff options
author | Yusuke Sakurai <kerokerokerop@gmail.com> | 2020-03-23 03:49:09 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 14:49:09 -0400 |
commit | c337d2c4349abd710b1ab0d4de3f1041cd02715c (patch) | |
tree | d6677ed54142beb192bbb48b2dfc2a1b3e4690d5 /std/textproto/mod.ts | |
parent | 07ea145ec4d1defe4481035432bb63234560ba8d (diff) |
clean up textproto code in std (#4458)
- moved and renamed append() into bytes from ws and textproto
- renamed textproto/readder_tests.ts -> textproto/test.ts
Diffstat (limited to 'std/textproto/mod.ts')
-rw-r--r-- | std/textproto/mod.ts | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/std/textproto/mod.ts b/std/textproto/mod.ts index b27b1d59b..760a068b5 100644 --- a/std/textproto/mod.ts +++ b/std/textproto/mod.ts @@ -5,24 +5,14 @@ import { BufReader } from "../io/bufio.ts"; import { charCode } from "../io/util.ts"; +import { concat } from "../bytes/mod.ts"; +import { decode } from "../strings/mod.ts"; -const asciiDecoder = new TextDecoder(); function str(buf: Uint8Array | null | undefined): string { if (buf == null) { return ""; } else { - return asciiDecoder.decode(buf); - } -} - -export function append(a: Uint8Array, b: Uint8Array): Uint8Array { - if (a == null) { - return b; - } else { - const output = new Uint8Array(a.length + b.length); - output.set(a, 0); - output.set(b, a.length); - return output; + return decode(buf); } } @@ -146,9 +136,7 @@ export class TextProtoReader { } return l; } - - // @ts-ignore - line = append(line, l); + line = line ? concat(line, l) : l; if (!more) { break; } |