vowel-changer
v1.0.1
Published
Replace all vowels in a word with the a specific vowel of your choice.
Downloads
4
Maintainers
Readme
VOWEL-CHANGER
Replace all vowels in a word with the a specific vowel of your choice. This package allows you to transform any word by replacing all of its vowels with a single vowel.
Instalation
npm install vowel-changerMake sure your
package.jsonincludes"type": "module"if you're working witch ES Modules.
Usage
import vowelChanger from "vowel-changer";
const result = vowelChanger("i", "murciélago");
console.log(result); // "mirciíligi"Parameters
givenVowel(string): The vowel that will replace all others.givenWord(string): The original word to be transformed.
Rules & Validation
- The vowel mus be one of:
a,e,i,o,u(case-insensitive) - Both arguments must be strings.
- Accents (diacritics) are remove before processing.
- If the input is invalid or missing, an error os thrown.
Examples:
vowelChanger("a", "educación"); // "adacacaán"
vowelChanger("o", "película"); // "polócolo"
vowelChanger("e", "murciélago"); // "merceélege"Error handling
This function throws an error when:
vowelChanger("x", "perro"); // Error: You must insert a vowel: a, e, i, o, u
vowelChanger(4, "perro"); // Error: Both arguments must be strings
vowelChanger("i"); // Error: You must introduce a vowel and a wordLicense
MIT
