Skip to content

Commit

Permalink
Refactor firstchar function for conciseness and modern syntax
Browse files Browse the repository at this point in the history
- Replaced var with const for improved variable management
- Used optional chaining for a more concise return statement
- Enhanced readability while preserving functionality
  • Loading branch information
Ayoub-Mabrouk committed Oct 31, 2024
1 parent a5055df commit aec6065
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/types/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,8 @@ function createStrictSyntaxError (str, char) {
*/

function firstchar (str) {
var match = FIRST_CHAR_REGEXP.exec(str)

return match
? match[1]
: undefined
const match = FIRST_CHAR_REGEXP.exec(str)
return match?.[1]
}

/**
Expand Down

0 comments on commit aec6065

Please # to comment.