Skip to content

Commit

Permalink
refactor: improve toClassName function readability and JSDoc complete…
Browse files Browse the repository at this point in the history
…ness

- 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.
  • Loading branch information
Ayoub-Mabrouk authored and wesleytodd committed Nov 12, 2024
1 parent 2526505 commit d8899ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Unreleased changes
==================

* improve toClassName function readability and JSDoc completeness

2.0.0 / 2021-12-17
==================

Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,12 @@ function populateConstructorExports (exports, codes, HttpError) {

/**
* Get a class name from a name identifier.
*
* @param {string} name
* @returns {string}
* @private
*/

function toClassName (name) {
return name.substr(-5) !== 'Error'
? name + 'Error'
: name
return name.slice(-5) === 'Error' ? name : name + 'Error'
}

0 comments on commit d8899ba

Please sign in to comment.