-
Notifications
You must be signed in to change notification settings - Fork 0
/
garble-min.js
1 lines (1 loc) · 1011 Bytes
/
garble-min.js
1
(function(){"use strict";function charRange(low,high){var result=[];for(var current=low.charCodeAt(0);current<=high.charCodeAt(0);current++){result.push(String.fromCharCode(current))}return result}var diacritics=charRange("̀","ͯ");function randomDiacritic(){return diacritics[Math.floor(Math.random()*diacritics.length)]}var garble=function(str,minDiacritics,maxDiacritics){var garbled="";minDiacritics=typeof minDiacritics==="undefined"?20:minDiacritics;maxDiacritics=typeof maxDiacritics==="undefined"?30:maxDiacritics;var diactricRange=maxDiacritics-minDiacritics+1;for(var c of str){garbled+=c;var numDiactritics=Math.floor(Math.random()*diactricRange)+minDiacritics;for(var j=0;j<numDiactritics;j++){garbled+=randomDiacritic()}}return garbled};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){exports=module.exports=garble}exports.garble=garble}else{this.garble=garble}if(typeof define==="function"&&define.amd){define("garble",[],function(){return garble})}}).call(this);