From 06a1c9bf80a4ea4ea1107ca425051cd679c8b40b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 16 Aug 2016 16:22:23 -0700 Subject: [PATCH] assert: remove code that is never reached MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/8132 Reviewed-By: Michaƫl Zasso Reviewed-By: Alexander Makarenko Reviewed-By: Yorkie Liu Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- lib/assert.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index c0f222d510e6c5..233ca4ddc86fcc 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -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) {