From 9042fcc12e7774cdd0ca3a5d08918a07dae8102b Mon Sep 17 00:00:00 2001 From: Steven Guerrero Date: Thu, 26 Nov 2020 07:50:08 -0500 Subject: feat(std/node/stream): Add Duplex, Transform, Passthrough, pipeline, finished and promises (#7940) --- std/node/_buffer.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'std/node/_buffer.ts') 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) { -- cgit v1.2.3