Skip to content

Commit f40e099

Browse files
BridgeARdanielleadams
authored andcommittedFeb 1, 2022
lib: do not lazy load EOL in blob
This addresses a comment by loading the EOL from the constants file. Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> PR-URL: #41004 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b15f5e4 commit f40e099

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed
 

‎lib/internal/blob.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ const disallowedTypeCharacters = /[^\u{0020}-\u{007E}]/u;
7575

7676
let ReadableStream;
7777
let URL;
78-
let EOL;
7978

8079
const enc = new TextEncoder();
8180

@@ -94,13 +93,7 @@ function lazyReadableStream(options) {
9493
return new ReadableStream(options);
9594
}
9695

97-
// TODO(@jasnell): This is annoying but this has to be lazy because
98-
// requiring the 'os' module too early causes building Node.js to
99-
// fail with an unknown reference failure.
100-
function lazyEOL() {
101-
EOL ??= require('os').EOL;
102-
return EOL;
103-
}
96+
const { EOL } = require('internal/constants');
10497

10598
function isBlob(object) {
10699
return object?.[kHandle] !== undefined;
@@ -115,7 +108,7 @@ function getSource(source, endings) {
115108
} else if (!isArrayBufferView(source)) {
116109
source = `${source}`;
117110
if (endings === 'native')
118-
source = RegExpPrototypeSymbolReplace(/\n|\r\n/g, source, lazyEOL());
111+
source = RegExpPrototypeSymbolReplace(/\n|\r\n/g, source, EOL);
119112
source = enc.encode(source);
120113
}
121114

0 commit comments

Comments
 (0)
Please sign in to comment.