Skip to content

Commit

Permalink
refactor: use map and join instead of reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
2wheeh committed Aug 5, 2024
1 parent 9ad42e6 commit e452b73
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/romanize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ const romanizeSyllableHangul = (arrayHangul: string[], index: number): string =>
}

if (hasProperty(DISASSEMBLED_CONSONANTS_BY_CONSONANT, syllable)) {
return DISASSEMBLED_CONSONANTS_BY_CONSONANT[syllable].split('').reduce((acc, consonant) => {
assert(hasProperty(초성_알파벳_발음, consonant), `${consonant}에 해당하는 알파벳 발음이 존재하지 않습니다.`);
return DISASSEMBLED_CONSONANTS_BY_CONSONANT[syllable]
.split('')
.map(consonant => {
assert(hasProperty(초성_알파벳_발음, consonant), `${consonant}에 해당하는 알파벳 발음이 존재하지 않습니다.`);

return acc + 초성_알파벳_발음[consonant];
}, '');
return 초성_알파벳_발음[consonant];
})
.join('');
}

return syllable;
Expand Down

0 comments on commit e452b73

Please sign in to comment.