mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 12:49:10 +00:00
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:
parent
07ea145ec4
commit
c337d2c434
6 changed files with 227 additions and 235 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue