owofi
Version:
Text owoifier library.
15 lines (10 loc) • 469 B
JavaScript
function owo(str) {
if (typeof str !== 'string') throw new TypeError('Expected a string to owoify');
str = str.replace(new RegExp('L', 'g'), 'W').replace(new RegExp('l', 'g'), 'w');
for (const v of ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']) {
if (str.includes(`n${v}`)) str.replace(new RegExp(`n${v}`, 'g'), `ny${v}`);
if (str.includes(`N${v}`)) str.replace(new RegExp(`N${v}`, 'g'), `Ny${v}`);
}
return str;
}
module.exports = owo;