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
This commit is contained in:
Yusuke Sakurai 2020-03-23 03:49:09 +09:00 committed by GitHub
parent 07ea145ec4
commit c337d2c434
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 227 additions and 235 deletions

View file

@ -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;
}