summaryrefslogtreecommitdiff
path: root/std/node/string_decoder.ts
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2020-07-14 15:24:17 -0400
committerGitHub <noreply@github.com>2020-07-14 15:24:17 -0400
commitcde4dbb35132848ffece59ef9cfaccff32347124 (patch)
treecc7830968c6decde704c8cfb83c9185193dc698f /std/node/string_decoder.ts
parent9eca71caa1674c31f9cc5d4e86c03f10b59e0a00 (diff)
Use dprint for internal formatting (#6682)
Diffstat (limited to 'std/node/string_decoder.ts')
-rw-r--r--std/node/string_decoder.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/std/node/string_decoder.ts b/std/node/string_decoder.ts
index 7f167ad3c..ce7c19538 100644
--- a/std/node/string_decoder.ts
+++ b/std/node/string_decoder.ts
@@ -31,8 +31,9 @@ enum NotImplemented {
function normalizeEncoding(enc?: string): string {
const encoding = castEncoding(enc ?? null);
if (encoding && encoding in NotImplemented) notImplemented(encoding);
- if (!encoding && typeof enc === "string" && enc.toLowerCase() !== "raw")
+ if (!encoding && typeof enc === "string" && enc.toLowerCase() !== "raw") {
throw new Error(`Unknown encoding: ${enc}`);
+ }
return String(encoding);
}
/*
@@ -55,7 +56,7 @@ function utf8CheckByte(byte: number): number {
function utf8CheckIncomplete(
self: StringDecoderBase,
buf: Buffer,
- i: number
+ i: number,
): number {
let j = buf.length - 1;
if (j < i) return 0;
@@ -94,7 +95,7 @@ function utf8CheckIncomplete(
* */
function utf8CheckExtraBytes(
self: StringDecoderBase,
- buf: Buffer
+ buf: Buffer,
): string | undefined {
if ((buf[0] & 0xc0) !== 0x80) {
self.lastNeed = 0;
@@ -119,7 +120,7 @@ function utf8CheckExtraBytes(
* */
function utf8FillLastComplete(
this: StringDecoderBase,
- buf: Buffer
+ buf: Buffer,
): string | undefined {
const p = this.lastTotal - this.lastNeed;
const r = utf8CheckExtraBytes(this, buf);
@@ -137,7 +138,7 @@ function utf8FillLastComplete(
* */
function utf8FillLastIncomplete(
this: StringDecoderBase,
- buf: Buffer
+ buf: Buffer,
): string | undefined {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
@@ -203,8 +204,9 @@ function base64Text(this: StringDecoderBase, buf: Buffer, i: number): string {
function base64End(this: Base64Decoder, buf?: Buffer): string {
const r = buf && buf.length ? this.write(buf) : "";
- if (this.lastNeed)
+ if (this.lastNeed) {
return r + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
+ }
return r;
}