Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5bc3119

Browse filesBrowse 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 <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>
1 parent c406ad8 commit 5bc3119
Copy full SHA for 5bc3119

File tree

Expand file treeCollapse file tree

1 file changed

+1
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-5
lines changed
Open diff view settings
Collapse file

‎lib/assert.js‎

Copy file name to clipboardExpand all lines: lib/assert.js
+1-5Lines 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
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.