Skip to content

Commit 373bbbc

Browse files
committed
refactor: improve oClassName 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 373bbbc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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)