Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor typeChecker function for conciseness and modern syntax #556

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 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 Expand Up @@ -244,7 +241,5 @@ function normalizeJsonSyntaxError (error, obj) {
*/

function typeChecker (type) {
return function checkType (req) {
return Boolean(typeis(req, type))
}
return (req) => Boolean(typeis(req, type))
}