Skip to content

Commit ed8ae88

Browse files
aduh95targos
authored andcommitted
lib: remove unnecessary lazy loading in internal/encoding
PR-URL: #45810 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent b5b56b6 commit ed8ae88

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/internal/encoding.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ const {
5656
decodeUTF8,
5757
} = internalBinding('buffer');
5858

59-
let Buffer;
60-
function lazyBuffer() {
61-
if (Buffer === undefined)
62-
Buffer = require('buffer').Buffer;
63-
return Buffer;
64-
}
59+
const { Buffer } = require('buffer');
6560

6661
function validateEncoder(obj) {
6762
if (obj == null || obj[kEncoder] !== true)
@@ -499,14 +494,14 @@ function makeTextDecoderJS() {
499494
validateDecoder(this);
500495
if (isAnyArrayBuffer(input)) {
501496
try {
502-
input = lazyBuffer().from(input);
497+
input = Buffer.from(input);
503498
} catch {
504499
input = empty;
505500
}
506501
} else if (isArrayBufferView(input)) {
507502
try {
508-
input = lazyBuffer().from(input.buffer, input.byteOffset,
509-
input.byteLength);
503+
input = Buffer.from(input.buffer, input.byteOffset,
504+
input.byteLength);
510505
} catch {
511506
input = empty;
512507
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy