Skip to content

Commit

Permalink
lib: do not lazy load EOL in blob
Browse files Browse the repository at this point in the history
This addresses a comment by loading the EOL from the constants file.

Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41004
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
BridgeAR authored and danielleadams committed Dec 13, 2021
1 parent 5fe6632 commit 6055081
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/internal/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const disallowedTypeCharacters = /[^\u{0020}-\u{007E}]/u;

let ReadableStream;
let URL;
let EOL;

const enc = new TextEncoder();

Expand All @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit 6055081

Please sign in to comment.