Skip to content

Commit

Permalink
refactor: alterado isJapanese para hasJapanese
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian-Sknz committed May 16, 2022
1 parent 0ef5460 commit 065aec6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/services/kuroshiro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ type APIData = {
lyrics: string;
};

function isJapanese(input: string) {
if (input.startsWith('「') && input.endsWith('」')) {
return Kuroshiro.Util.isJapanese(input.substring(1, input.length - 1));
}

return Kuroshiro.Util.isJapanese(input);
}
const { hasJapanese } = Kuroshiro.Util;

export async function toRomaji(lyrics: Lyrics) {
return loader.then(async (value) => {
const data = await Promise.all(lyrics.map(({text}) => {
if (isJapanese(text)) {
if (hasJapanese(text)) {
return value.convert(text.replace(/\s/g, ''), {
to: 'romaji',
mode: 'spaced',
Expand Down

0 comments on commit 065aec6

Please sign in to comment.