Skip to content

Commit d8899ba

Browse files
Ayoub-Mabroukwesleytodd
authored andcommitted
refactor: improve toClassName function readability and JSDoc completeness
- Replaced substr with slice for better readability and consistency. - Updated JSDoc to include @param and @returns tags for clarity on function inputs and outputs. - Simplified the conditional logic by using slice(-5) === 'Error' for a concise and clear check.
1 parent 2526505 commit d8899ba

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Unreleased changes
2+
==================
3+
4+
* improve toClassName function readability and JSDoc completeness
5+
16
2.0.0 / 2021-12-17
27
==================
38

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,12 @@ function populateConstructorExports (exports, codes, HttpError) {
279279

280280
/**
281281
* Get a class name from a name identifier.
282+
*
283+
* @param {string} name
284+
* @returns {string}
282285
* @private
283286
*/
284287

285288
function toClassName (name) {
286-
return name.substr(-5) !== 'Error'
287-
? name + 'Error'
288-
: name
289+
return name.slice(-5) === 'Error' ? name : name + 'Error'
289290
}

0 commit comments

Comments
 (0)