Skip to content

Commit 06a1c9b

Browse files
TrottMylesBorins
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 9c826be commit 06a1c9b

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/assert.js

+1-5
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
function truncate(s, n) {
64-
if (typeof s === 'string') {
65-
return s.length < n ? s : s.slice(0, n);
66-
} else {
67-
return s;
68-
}
64+
return s.slice(0, n);
6965
}
7066

7167
function getMessage(self) {

0 commit comments

Comments
 (0)