summaryrefslogtreecommitdiff
path: root/std/node/_string_decoder.ts
diff options
context:
space:
mode:
authorSteven Guerrero <stephenguerrero43@gmail.com>2020-11-26 07:50:08 -0500
committerGitHub <noreply@github.com>2020-11-26 13:50:08 +0100
commit9042fcc12e7774cdd0ca3a5d08918a07dae8102b (patch)
tree8b5ff11412aae9bb714e0bb0b9b0358db64a8657 /std/node/_string_decoder.ts
parent60e980c78180ee3b0a14d692307be275dc181c8d (diff)
feat(std/node/stream): Add Duplex, Transform, Passthrough, pipeline, finished and promises (#7940)
Diffstat (limited to 'std/node/_string_decoder.ts')
-rw-r--r--std/node/_string_decoder.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/std/node/_string_decoder.ts b/std/node/_string_decoder.ts
index ce7c19538..623070f58 100644
--- a/std/node/_string_decoder.ts
+++ b/std/node/_string_decoder.ts
@@ -172,7 +172,13 @@ function utf8End(this: Utf8Decoder, buf?: Buffer): string {
return r;
}
-function utf8Write(this: Utf8Decoder | Base64Decoder, buf: Buffer): string {
+function utf8Write(
+ this: Utf8Decoder | Base64Decoder,
+ buf: Buffer | string,
+): string {
+ if (typeof buf === "string") {
+ return buf;
+ }
if (buf.length === 0) return "";
let r;
let i;
@@ -210,7 +216,13 @@ function base64End(this: Base64Decoder, buf?: Buffer): string {
return r;
}
-function simpleWrite(this: StringDecoderBase, buf: Buffer): string {
+function simpleWrite(
+ this: StringDecoderBase,
+ buf: Buffer | string,
+): string {
+ if (typeof buf === "string") {
+ return buf;
+ }
return buf.toString(this.encoding);
}