git-off

git off handles large files in git repos
git clone https://noulin.net/git/git-off.git
Log | Files | Refs | README

zalgo.js (2845B)


      1 // please no
      2 module['exports'] = function zalgo(text, options) {
      3   text = text || "   he is here   ";
      4   var soul = {
      5     "up" : [
      6       '̍', '̎', '̄', '̅',
      7       '̿', '̑', '̆', '̐',
      8       '͒', '͗', '͑', '̇',
      9       '̈', '̊', '͂', '̓',
     10       '̈', '͊', '͋', '͌',
     11       '̃', '̂', '̌', '͐',
     12       '̀', '́', '̋', '̏',
     13       '̒', '̓', '̔', '̽',
     14       '̉', 'ͣ', 'ͤ', 'ͥ',
     15       'ͦ', 'ͧ', 'ͨ', 'ͩ',
     16       'ͪ', 'ͫ', 'ͬ', 'ͭ',
     17       'ͮ', 'ͯ', '̾', '͛',
     18       '͆', '̚'
     19     ],
     20     "down" : [
     21       '̖', '̗', '̘', '̙',
     22       '̜', '̝', '̞', '̟',
     23       '̠', '̤', '̥', '̦',
     24       '̩', '̪', '̫', '̬',
     25       '̭', '̮', '̯', '̰',
     26       '̱', '̲', '̳', '̹',
     27       '̺', '̻', '̼', 'ͅ',
     28       '͇', '͈', '͉', '͍',
     29       '͎', '͓', '͔', '͕',
     30       '͖', '͙', '͚', '̣'
     31     ],
     32     "mid" : [
     33       '̕', '̛', '̀', '́',
     34       '͘', '̡', '̢', '̧',
     35       '̨', '̴', '̵', '̶',
     36       '͜', '͝', '͞',
     37       '͟', '͠', '͢', '̸',
     38       '̷', '͡', ' ҉'
     39     ]
     40   },
     41   all = [].concat(soul.up, soul.down, soul.mid),
     42   zalgo = {};
     43 
     44   function randomNumber(range) {
     45     var r = Math.floor(Math.random() * range);
     46     return r;
     47   }
     48 
     49   function is_char(character) {
     50     var bool = false;
     51     all.filter(function (i) {
     52       bool = (i === character);
     53     });
     54     return bool;
     55   }
     56   
     57 
     58   function heComes(text, options) {
     59     var result = '', counts, l;
     60     options = options || {};
     61     options["up"] =   typeof options["up"]   !== 'undefined' ? options["up"]   : true;
     62     options["mid"] =  typeof options["mid"]  !== 'undefined' ? options["mid"]  : true;
     63     options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true;
     64     options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi";
     65     text = text.split('');
     66     for (l in text) {
     67       if (is_char(l)) {
     68         continue;
     69       }
     70       result = result + text[l];
     71       counts = {"up" : 0, "down" : 0, "mid" : 0};
     72       switch (options.size) {
     73       case 'mini':
     74         counts.up = randomNumber(8);
     75         counts.mid = randomNumber(2);
     76         counts.down = randomNumber(8);
     77         break;
     78       case 'maxi':
     79         counts.up = randomNumber(16) + 3;
     80         counts.mid = randomNumber(4) + 1;
     81         counts.down = randomNumber(64) + 3;
     82         break;
     83       default:
     84         counts.up = randomNumber(8) + 1;
     85         counts.mid = randomNumber(6) / 2;
     86         counts.down = randomNumber(8) + 1;
     87         break;
     88       }
     89 
     90       var arr = ["up", "mid", "down"];
     91       for (var d in arr) {
     92         var index = arr[d];
     93         for (var i = 0 ; i <= counts[index]; i++) {
     94           if (options[index]) {
     95             result = result + soul[index][randomNumber(soul[index].length)];
     96           }
     97         }
     98       }
     99     }
    100     return result;
    101   }
    102   // don't summon him
    103   return heComes(text, options);
    104 }