Skip to content

Commit

Permalink
refactor: hasSingleBatchim 내 early return 패턴 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-moon committed Apr 22, 2024
1 parent dfdc14e commit 59f0379
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ export function hasBatchim(str: string) {
*/
export function hasSingleBatchim(str: string) {
const lastChar = str[str.length - 1]!;
const disassembled = disassembleHangul(lastChar);
if (hasBatchim(lastChar) === false) {
return false;
}

return hasBatchim(lastChar) && disassembled.length === 3;
const disassembled = disassembleHangul(lastChar);
return disassembled.length === 3;
}

/**
Expand Down

0 comments on commit 59f0379

Please sign in to comment.