From c337d2c4349abd710b1ab0d4de3f1041cd02715c Mon Sep 17 00:00:00 2001 From: Yusuke Sakurai Date: Mon, 23 Mar 2020 03:49:09 +0900 Subject: 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 --- std/textproto/mod.ts | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'std/textproto/mod.ts') 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; } -- cgit v1.2.3