Skip to content

Commit 5bc3119

Browse files
Trottevanlucas
authored andcommitted
assert: remove code that is never reached
The internal function `truncate()` is only called with the first argument being the output of `util.inspect()`. `util.inspect()` calls its own internal `formatValue()` which is guaranteed to return a string. Therefore, we can remove the check in `truncate()` that the first argument is a string as well as code to handle the case where it is not a string. PR-URL: #8132 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Alexander Makarenko <[email protected]> Reviewed-By: Yorkie Liu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent c406ad8 commit 5bc3119

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

‎lib/assert.js‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ assert.AssertionError = function AssertionError(options){
6161
util.inherits(assert.AssertionError,Error);
6262

6363
functiontruncate(s,n){
64-
if(typeofs==='string'){
65-
returns.length<n ? s : s.slice(0,n);
66-
}else{
67-
returns;
68-
}
64+
returns.slice(0,n);
6965
}
7066

7167
functiongetMessage(self){

0 commit comments

Comments
(0)