Skip to content

Commit b19ffeb

Browse files
kt3kaduh95
authored andcommitted
assert: remove dead code
PR-URL: #58760 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
1 parent 3fd187f commit b19ffeb

1 file changed

Lines changed: 16 additions & 25 deletions

File tree

‎lib/internal/assert/utils.js‎

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const {
99
SafeMap,
1010
StringPrototypeCharCodeAt,
1111
StringPrototypeIncludes,
12-
StringPrototypeIndexOf,
1312
StringPrototypeReplace,
1413
StringPrototypeSlice,
1514
StringPrototypeSplit,
@@ -174,7 +173,6 @@ function getErrMessage(message, fn) {
174173
constline=call.getLineNumber()-1;
175174
letcolumn=call.getColumnNumber()-1;
176175
letidentifier;
177-
letcode;
178176

179177
if(filename){
180178
identifier=`${filename}${line}${column}`;
@@ -199,31 +197,24 @@ function getErrMessage(message, fn) {
199197
// errors are handled faster.
200198
if(errorStackTraceLimitIsWritable)Error.stackTraceLimit=0;
201199

202-
if(filename){
203-
if(decoder===undefined){
204-
const{ StringDecoder }=require('string_decoder');
205-
decoder=newStringDecoder('utf8');
206-
}
207-
208-
// ESM file prop is a file proto. Convert that to path.
209-
// This ensure opensync will not throw ENOENT for ESM files.
210-
constfileProtoPrefix='file://';
211-
if(StringPrototypeStartsWith(filename,fileProtoPrefix)){
212-
filename=fileURLToPath(filename);
213-
}
200+
if(decoder===undefined){
201+
const{ StringDecoder }=require('string_decoder');
202+
decoder=newStringDecoder('utf8');
203+
}
214204

215-
fd=openSync(filename,'r',0o666);
216-
// Reset column and message.
217-
({0: column,1: message}=getCode(fd,line,column));
218-
// Flush unfinished multi byte characters.
219-
decoder.end();
220-
}else{
221-
for(leti=0;i<line;i++){
222-
code=StringPrototypeSlice(code,
223-
StringPrototypeIndexOf(code,'\n')+1);
224-
}
225-
({0: column,1: message}=parseCode(code,column));
205+
// ESM file prop is a file proto. Convert that to path.
206+
// This ensure opensync will not throw ENOENT for ESM files.
207+
constfileProtoPrefix='file://';
208+
if(StringPrototypeStartsWith(filename,fileProtoPrefix)){
209+
filename=fileURLToPath(filename);
226210
}
211+
212+
fd=openSync(filename,'r',0o666);
213+
// Reset column and message.
214+
({0: column,1: message}=getCode(fd,line,column));
215+
// Flush unfinished multi byte characters.
216+
decoder.end();
217+
227218
// Always normalize indentation, otherwise the message could look weird.
228219
if(StringPrototypeIncludes(message,'\n')){
229220
if(EOL==='\r\n'){

0 commit comments

Comments
 (0)