Typoglycemia in Coffeescript
Typoglycemia = () -> text = arguments out =  params = arguments or  level = params.level or 'soft' # soft|hard minChars = params.minChars or 4 maxChars = params.maxChars or 8 processWord = (_word) -> return _word if _word.length < minChars return _word if _word.length > maxChars and level is 'soft' _word = _word.split('') first = [_word.shift()] last = [_word.pop()] i = _word.length while --i j = Math.floor(Math.random() * (i + 1)) temp = _word[i] _word[i] = _word[j] _word[j] = temp _word.unshift first _word.push last _word.join '' words = text.split(' ') for word in words out.push processWord word out.join ' '
Typoglycemia "String with multiple words"
Snitrg with mlutiple words
Typoglycemia "I couldn't believe that I could actually understand what I was reading The phenomenal power of the human mind According to a research at Cambrigde University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be in the right place. The rest can be a total mess and you can still read it without a problem. This is because the human mind does not read every letter by itself, but the word as a whole. Amazing huh? Yeah and I always thought spelling was important. "
I cndlo'ut beveile that I cloud aaultlcy understand what I was renaidg The phenomenal pwoer of the hmuan mnid According to a raceersh at Cambrigde University, it dose'nt matetr in waht oedrr the leretts in a word are, the olny important tihng is that the frsit and lsat leettr be in the rghit pacle. The rest can be a tatol mess and you can slitl read it wotiuht a plemorb. Tihs is bcuseae the hmuan mind deos not read evrey lteter by iletsf, but the word as a wolhe. Amanizg hhu? Yaeh and I aawyls thhugot sllenipg was important.
Available at npm and bower.