diff options
author | Steven Guerrero <stephenguerrero43@gmail.com> | 2020-11-26 07:50:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-26 13:50:08 +0100 |
commit | 9042fcc12e7774cdd0ca3a5d08918a07dae8102b (patch) | |
tree | 8b5ff11412aae9bb714e0bb0b9b0358db64a8657 /std/node/_buffer.ts | |
parent | 60e980c78180ee3b0a14d692307be275dc181c8d (diff) |
feat(std/node/stream): Add Duplex, Transform, Passthrough, pipeline, finished and promises (#7940)
Diffstat (limited to 'std/node/_buffer.ts')
-rw-r--r-- | std/node/_buffer.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/std/node/_buffer.ts b/std/node/_buffer.ts index 8cbd117ca..d7e8af6ee 100644 --- a/std/node/_buffer.ts +++ b/std/node/_buffer.ts @@ -1,7 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import * as hex from "../encoding/hex.ts"; import * as base64 from "../encoding/base64.ts"; -import { normalizeEncoding, notImplemented } from "./_utils.ts"; +import { Encodings, normalizeEncoding, notImplemented } from "./_utils.ts"; const notImplementedEncodings = [ "ascii", @@ -11,7 +11,7 @@ const notImplementedEncodings = [ "utf16le", ]; -function checkEncoding(encoding = "utf8", strict = true): string { +function checkEncoding(encoding = "utf8", strict = true): Encodings { if (typeof encoding !== "string" || (strict && encoding === "")) { if (!strict) return "utf8"; throw new TypeError(`Unkown encoding: ${encoding}`); @@ -93,14 +93,14 @@ export class Buffer extends Uint8Array { let bufFill; if (typeof fill === "string") { - encoding = checkEncoding(encoding); + const clearEncoding = checkEncoding(encoding); if ( typeof fill === "string" && fill.length === 1 && - encoding === "utf8" + clearEncoding === "utf8" ) { buf.fill(fill.charCodeAt(0)); - } else bufFill = Buffer.from(fill, encoding); + } else bufFill = Buffer.from(fill, clearEncoding); } else if (typeof fill === "number") { buf.fill(fill); } else if (fill instanceof Uint8Array) { |