import { Conjugator } from '@jirimracek/conjugate-esp'; const internals = { kVowels: ['a', 'e', 'i', 'o', 'u'], }; export const pluralize = function (noun) { const lastLetter = noun[noun.length - 1]; if (lastLetter === 's') { return noun; } if (internals.kVowels.indexOf(lastLetter) >= 0) { return noun + 's' } return noun + 'es'; }; export const conjugate = async function(verb) { const conjugator = new Conjugator(); try { const conjugation = await conjugator.conjugate(verb); if (!conjugation || conjugation.length === 0) { console.error('Could not conjugate: ', verb); throw new Error(`Could not conjugate: ${verb}`) } const presentIndicative = conjugation[0] .conjugation .Indicativo .Presente[2]; return presentIndicative; } catch (err) { return verb.replace(/r$/, ''); } };