Created
July 1, 2016 21:47
-
-
Save Gwash3189/d3b5c45943ac7eae9e3a593c9c5d55f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const twistUp = (str) => { | |
const lookup = { | |
'a': 'áăắặằẳẵǎâấậầẩẫäạàảāąåǻãɑɐɒ', | |
'b': 'ḅɓß♭␢Б', | |
'c': 'ćčçĉɕċ', | |
'd': 'ďḓḍɗḏđɖ', | |
'e': 'éĕěêếệềểễëėẹèẻēęẽɘəɚ', | |
'f': 'ƒſʃʆʅɟʄ', | |
'g': 'ǵğǧģĝġɠḡɡ', | |
'h': 'ḫĥḥɦẖħɧ', | |
'i': 'íĭǐîïịìỉīįɨĩɩı', | |
'j': 'ǰĵʝȷɟʄ', | |
'k': 'ķḳƙḵĸʞ', | |
'l': 'ĺƚɬľļḽḷḹḻŀɫɭł', | |
'm': 'ḿṁṃɱɯɰ', | |
'n': 'ʼnńňņṋṅṇǹɲṉɳñŋ', | |
'o': 'óŏǒôốộồổỗöọőòỏơớợờởỡōǫøǿõɵʘ', | |
'p': 'ɸþᵱƥᵽṗṕ', | |
'q': 'ʠꝗɋq̃ϙ', | |
'r': 'ŕřŗṙṛṝɾṟɼɽɿɹɻ', | |
's': 'śšşŝșṡṣʂ', | |
't': 'ťţṱțẗṭṯʈŧ', | |
'u': 'ʉúŭǔûüǘǚǜǖụűùủưứựừửữūųůũʊ', | |
'v': 'ʋʌⱴṿṽ', | |
'w': 'ẃŵẅẁʍ', | |
'x': 'χẍẋⲭ', | |
'y': 'ýŷÿẏỵỳƴỷȳỹʎ', | |
'z': 'źžʑżẓẕʐƶ', | |
'A': 'ÁĂẮẶẰẲẴǍÂẤẬẦẨẪÄẠÀẢĀĄÅǺÃ', | |
'B': 'ḄƁᛒ𐌱ɃḂḆ฿β', | |
'C': 'ĆČÇĈĊƆʗ', | |
'D': 'ĎḒḌƊḎĐÐ', | |
'E': 'ÉĔĚÊẾỆỀỂỄËĖẸÈẺĒĘẼƐ', | |
'F': 'ƑḞ𐌅₣', | |
'G': 'ǴĞǦĢĜĠḠʛ', | |
'H': 'ḪĤḤĦ', | |
'I': 'ÍĬǏÎÏİỊÌỈĪĮĨ', | |
'J': 'ĴɈʝ', | |
'K': 'ĶḲƘḴ', | |
'L': 'ĹȽĽĻḼḶḸḺĿŁ', | |
'M': 'ḾṀṂ', | |
'N': 'ŃŇŅṊṄṆǸƝṈÑ', | |
'O': 'ÓŎǑÔỐỘỒỔỖÖỌŐÒỎƠỚỢỜỞỠŌƟǪØǾÕ', | |
'P': 'Þ𐌐ṔṖⱣƤ₱♇', | |
'Q': 'ꝖɊ', | |
'R': 'ŔŘŖṘṚṜṞʁ', | |
'S': 'ŚŠŞŜȘṠṢ', | |
'T': 'ŤŢṰȚṬṮŦ', | |
'U': 'ÚŬǓÛÜǗǙǛǕỤŰÙỦƯỨỰỪỬỮŪŲŮŨ', | |
'V': 'ṼṾƲ℣∨', | |
'W': 'ẂŴẄẀʬ', | |
'X': 'χẌẊⲬ𐍇', | |
'Y': 'ÝŶŸẎỴỲƳỶȲỸ', | |
'Z': 'ŹŽŻẒẔƵ' | |
} | |
const replaceWith = (lookup) => (char) => chooseRandChar(lookup[char]) || char | |
const reduce = (thing, fn, init = null) => { | |
let start = init | |
for(let i = 0; i < thing.length; i++) { | |
start = start + fn(thing[i], i, thing) | |
} | |
return start | |
} | |
const getRandomInt = (max, min = 0) => { | |
return Math.floor(Math.random() * (max - min)) + min; | |
} | |
const chooseRandChar = (str) => str ? str[getRandomInt(str.length - 1)] : str | |
return reduce(str, replaceWith(lookup), '') | |
} | |
console.log(twistUp(`For, after all, how do we know that two and two make four? | |
Or that the force of gravity works? Or that the past is unchangeable? | |
If both the past and the external world exist only in the mind, | |
and if the mind itself is controllable – what then?`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment