Skip to content

Commit 44cfe5e

Browse files
aduh95danielleadams
authored andcommitted
lib: remove unnecessary lazy loading in internal/encoding
PR-URL: #45810 Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent c64692e commit 44cfe5e

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
@@ -57,12 +57,7 @@ const {
5757
decodeUTF8,
5858
} = internalBinding('buffer');
5959

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

6762
function validateEncoder(obj) {
6863
if (obj == null || obj[kEncoder] !== true)
@@ -517,14 +512,14 @@ function makeTextDecoderJS() {
517512
validateDecoder(this);
518513
if (isAnyArrayBuffer(input)) {
519514
try {
520-
input = lazyBuffer().from(input);
515+
input = Buffer.from(input);
521516
} catch {
522517
input = empty;
523518
}
524519
} else if (isArrayBufferView(input)) {
525520
try {
526-
input = lazyBuffer().from(input.buffer, input.byteOffset,
527-
input.byteLength);
521+
input = Buffer.from(input.buffer, input.byteOffset,
522+
input.byteLength);
528523
} catch {
529524
input = empty;
530525
}

0 commit comments

Comments
 (0)