modusifier
Version:
A joke package that makes your text as if it were spoken by Modus from Fallout 76.
16 lines • 669 B
JavaScript
module.exports = function modusify(string = 'The quick brown fox jumps over the lazy dog') {
if (typeof string !== "string") throw new TypeError("String required! Received: " + typeof string);
string = string.split(' ');
const times = Math.round((Math.random() * (Math.ceil(string.length/5) - 1) + 1));
for (i=0;i<times;i++) {
const j = Math.floor(Math.random() * string.length);
string.splice(j, 0, '...');
}
const re = / \.\.\./g
string = string.join(' ').toString().replace(re,'...');
if (string.startsWith('... ')) {
return string.replace('... ','')
} else {
return string
}
};