Skip to content

Commit

Permalink
refactor(tokenizer): Use ternary
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed May 20, 2022
1 parent 2ec22a2 commit edb85df
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/parse5/lib/tokenizer/index.ts
Expand Up @@ -583,13 +583,11 @@ export class Tokenizer {
}

private _emitCodePoint(cp: number): void {
let type = TokenType.CHARACTER;

if (isWhitespace(cp)) {
type = TokenType.WHITESPACE_CHARACTER;
} else if (cp === $.NULL) {
type = TokenType.NULL_CHARACTER;
}
const type = isWhitespace(cp)
? TokenType.WHITESPACE_CHARACTER
: cp === $.NULL
? TokenType.NULL_CHARACTER
: TokenType.CHARACTER;

this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));
}
Expand Down

0 comments on commit edb85df

Please sign in to comment.