Permalink
Browse files

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 <targos@protonmail.com>
Reviewed-By: Alexander Makarenko <estliberitas@gmail.com>
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
Trott committed Aug 16, 2016
1 parent a9387db commit 2e59ccecde2a2d4a5a72b3372896427e28fc3265
Showing with 1 addition and 5 deletions.
  1. +1 −5 lib/assert.js
View
@@ -61,11 +61,7 @@ assert.AssertionError = function AssertionError(options) {
util.inherits(assert.AssertionError, Error);
function truncate(s, n) {
if (typeof s === 'string') {
return s.length < n ? s : s.slice(0, n);
} else {
return s;
}
return s.slice(0, n);
}
function getMessage(self) {

0 comments on commit 2e59cce

Please sign in to comment.