mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
0a9cb170fe
commit
9121bb301f
1 changed files with 2 additions and 9 deletions
|
@ -75,7 +75,6 @@ const disallowedTypeCharacters = /[^\u{0020}-\u{007E}]/u;
|
|||
|
||||
let ReadableStream;
|
||||
let URL;
|
||||
let EOL;
|
||||
|
||||
const enc = new TextEncoder();
|
||||
|
||||
|
@ -94,13 +93,7 @@ function lazyReadableStream(options) {
|
|||
return new ReadableStream(options);
|
||||
}
|
||||
|
||||
// TODO(@jasnell): This is annoying but this has to be lazy because
|
||||
// requiring the 'os' module too early causes building Node.js to
|
||||
// fail with an unknown reference failure.
|
||||
function lazyEOL() {
|
||||
EOL ??= require('os').EOL;
|
||||
return EOL;
|
||||
}
|
||||
const { EOL } = require('internal/constants');
|
||||
|
||||
function isBlob(object) {
|
||||
return object?.[kHandle] !== undefined;
|
||||
|
@ -115,7 +108,7 @@ function getSource(source, endings) {
|
|||
} else if (!isArrayBufferView(source)) {
|
||||
source = `${source}`;
|
||||
if (endings === 'native')
|
||||
source = RegExpPrototypeSymbolReplace(/\n|\r\n/g, source, lazyEOL());
|
||||
source = RegExpPrototypeSymbolReplace(/\n|\r\n/g, source, EOL);
|
||||
source = enc.encode(source);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue