UNPKG

monster-mash

Version:

A generator of more memorable and pretty unique IDs (especially in the sense of "that's an ID you don't see every day!").

7 lines (5 loc) 15.5 kB
(function(p,b){typeof exports=="object"&&typeof module!="undefined"?module.exports=b():typeof define=="function"&&define.amd?define(b):(p=typeof globalThis!="undefined"?globalThis:p||self,p.getUniqueMonster=b())})(this,function(){"use strict";var p={exports:{}};(function(u){function o(e,c){return Array.isArray(c)&&c.length?e.mersenne.seed_array(c):isNaN(c)||e.mersenne.seed(c),this.number=function(n){typeof n=="number"&&(n={max:n}),n=n||{},typeof n.min=="undefined"&&(n.min=0),typeof n.max=="undefined"&&(n.max=99999),typeof n.precision=="undefined"&&(n.precision=1);var r=n.max;r>=0&&(r+=n.precision);var a=Math.floor(e.mersenne.rand(r/n.precision,n.min/n.precision));return a=a/(1/n.precision),a},this.float=function(n){typeof n=="number"&&(n={precision:n}),n=n||{};var r={};for(var a in n)r[a]=n[a];return typeof r.precision=="undefined"&&(r.precision=.01),e.datatype.number(r)},this.datetime=function(n){typeof n=="number"&&(n={max:n});var r=864e13;n=n||{},(typeof n.min=="undefined"||n.min<r*-1)&&(n.min=new Date().setFullYear(1990,1,1)),(typeof n.max=="undefined"||n.max>r)&&(n.max=new Date().setFullYear(2100,1,1));var a=e.datatype.number(n);return new Date(a)},this.string=function(n){n===void 0&&(n=10);var r=Math.pow(2,20);n>=r&&(n=r);for(var a={min:33,max:125},t="",m=0;m<n;m++)t+=String.fromCharCode(e.datatype.number(a));return t},this.uuid=function(){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",r=function(a){var t=e.datatype.number({min:0,max:15}),m=a=="x"?t:t&3|8;return m.toString(16)};return n.replace(/[xy]/g,r)},this.boolean=function(){return!!e.datatype.number(1)},this.hexaDecimal=function(r){typeof r=="undefined"&&(r=1);for(var a="",t=0;t<r;t++)a+=e.random.arrayElement(["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","A","B","C","D","E","F"]);return"0x"+a},this.json=function(){var r=["foo","bar","bike","a","b","name","prop"],a={};return r.forEach(function(t){a[t]=e.datatype.boolean()?e.datatype.string():e.datatype.number()}),JSON.stringify(a)},this.array=function(r){r===void 0&&(r=10);for(var a=new Array(r),t=0;t<r;t++)a[t]=e.datatype.boolean()?e.datatype.string():e.datatype.number();return a},this}u.exports=o})(p);var b=p.exports,N={};function D(){var u,o,e,c,n;u=624,o=397,e=2567483615,c=2147483648,n=2147483647;var r=new Array(u),a=u+1;function t(i){return i<0?(i^c)+c:i}function m(i,s){return i<s?t(4294967296-(s-i)&4294967295):i-s}function d(i,s){return t(i+s&4294967295)}function h(i,s){for(var l=0,y=0;y<32;++y)i>>>y&1&&(l=d(l,t(s<<y)));return l}this.init_genrand=function(i){for(r[0]=t(i&4294967295),a=1;a<u;a++)r[a]=d(h(1812433253,t(r[a-1]^r[a-1]>>>30)),a),r[a]=t(r[a]&4294967295)},this.init_by_array=function(i,s){var l,y,v;for(this.init_genrand(19650218),l=1,y=0,v=u>s?u:s;v;v--)r[l]=d(d(t(r[l]^h(t(r[l-1]^r[l-1]>>>30),1664525)),i[y]),y),r[l]=t(r[l]&4294967295),l++,y++,l>=u&&(r[0]=r[u-1],l=1),y>=s&&(y=0);for(v=u-1;v;v--)r[l]=m(t((dbg=r[l])^h(t(r[l-1]^r[l-1]>>>30),1566083941)),l),r[l]=t(r[l]&4294967295),l++,l>=u&&(r[0]=r[u-1],l=1);r[0]=2147483648};var f=[0,e];this.genrand_int32=function(){var i;if(a>=u){var s;for(a==u+1&&this.init_genrand(5489),s=0;s<u-o;s++)i=t(r[s]&c|r[s+1]&n),r[s]=t(r[s+o]^i>>>1^f[i&1]);for(;s<u-1;s++)i=t(r[s]&c|r[s+1]&n),r[s]=t(r[s+(o-u)]^i>>>1^f[i&1]);i=t(r[u-1]&c|r[0]&n),r[u-1]=t(r[o-1]^i>>>1^f[i&1]),a=0}return i=r[a++],i=t(i^i>>>11),i=t(i^i<<7&2636928640),i=t(i^i<<15&4022730752),i=t(i^i>>>18),i},this.genrand_int31=function(){return this.genrand_int32()>>>1},this.genrand_real1=function(){return this.genrand_int32()*(1/4294967295)},this.genrand_real2=function(){return this.genrand_int32()*(1/4294967296)},this.genrand_real3=function(){return(this.genrand_int32()+.5)*(1/4294967296)},this.genrand_res53=function(){var i=this.genrand_int32()>>>5,s=this.genrand_int32()>>>6;return(i*67108864+s)*(1/9007199254740992)}}N.MersenneTwister19937=D;var A=N.MersenneTwister19937;function M(){var u=new A;u.init_genrand(new Date().getTime()%1e9),this.rand=function(o,e){return o===void 0&&(e=0,o=32768),Math.floor(u.genrand_real2()*(o-e)+e)},this.seed=function(o){if(typeof o!="number")throw new Error("seed(S) must take numeric argument; is "+typeof o);u.init_genrand(o)},this.seed_array=function(o){if(typeof o!="object")throw new Error("seed_array(A) must take array of numbers; is "+typeof o);u.init_by_array(o,o.length)}}var _=M,E={exports:{}},x={},w={},R=[],q=0,P=function(u,o){return typeof u[o]=="undefined"?-1:0};x.errorMessage=function(u,o,e){throw console.error("error",o),console.log("found",Object.keys(w).length,`unique entries before throwing error. retried:`,q,` total time:`,u-e.startTime,"ms"),new Error(o+` for uniqueness check May not be able to generate any more unique values with current settings. Try adjusting maxTime or maxRetries parameters for faker.unique()`)},x.exec=function(u,o,e){var c=new Date().getTime();e=e||{},e.maxTime=e.maxTime||3,e.maxRetries=e.maxRetries||50,e.exclude=e.exclude||R,e.compare=e.compare||P,typeof e.currentIterations!="number"&&(e.currentIterations=0),typeof e.startTime=="undefined"&&(e.startTime=new Date().getTime());var n=e.startTime;if(typeof e.exclude=="string"&&(e.exclude=[e.exclude]),e.currentIterations>0,c-n>=e.maxTime)return x.errorMessage(c,"Exceeded maxTime:"+e.maxTime,e);if(e.currentIterations>=e.maxRetries)return x.errorMessage(c,"Exceeded maxRetries:"+e.maxRetries,e);var r=u.apply(this,o);return e.compare(w,r)===-1&&e.exclude.indexOf(r)===-1?(w[r]=r,e.currentIterations=0,r):(e.currentIterations++,x.exec(u,o,e))};var I=x;(function(u){var o=I;function e(c){var n=10,r=10;this.unique=function(t,m,d){return d=d||{},d.startTime=new Date().getTime(),typeof d.maxTime!="number"&&(d.maxTime=n),typeof d.maxRetries!="number"&&(d.maxRetries=r),d.currentIterations=0,o.exec(t,m,d)}}u.exports=e})(E);var j=E.exports,T={exports:{}};(function(u){var o=function(c,n){return n.forEach(function(r){c=c.filter(function(a){return a!==r})}),c};function e(c,n){return Array.isArray(n)&&n.length?c.mersenne.seed_array(n):isNaN(n)||c.mersenne.seed(n),this.number=function(r){return console.log("Deprecation Warning: faker.random.number is now located in faker.datatype.number"),c.datatype.number(r)},this.float=function(r){return console.log("Deprecation Warning: faker.random.float is now located in faker.datatype.float"),c.datatype.float(r)},this.arrayElement=function(r){r=r||["a","b","c"];var a=c.datatype.number({max:r.length-1});return r[a]},this.arrayElements=function(r,a){r=r||["a","b","c"],typeof a!="number"?a=c.datatype.number({min:1,max:r.length}):a>r.length?a=r.length:a<0&&(a=0);for(var t=r.slice(0),m=r.length,d=m-a,h,f;m-- >d;)f=Math.floor((m+1)*c.datatype.float({min:0,max:.99})),h=t[f],t[f]=t[m],t[m]=h;return t.slice(d)},this.objectElement=function(r,a){r=r||{foo:"bar",too:"car"};var t=Object.keys(r),m=c.random.arrayElement(t);return a==="key"?m:r[m]},this.uuid=function(){return console.log("Deprecation Warning: faker.random.uuid is now located in faker.datatype.uuid"),c.datatype.uuid()},this.boolean=function(){return console.log("Deprecation Warning: faker.random.boolean is now located in faker.datatype.boolean"),c.datatype.boolean()},this.word=function(a){var t=["commerce.department","commerce.productName","commerce.productAdjective","commerce.productMaterial","commerce.product","commerce.color","company.catchPhraseAdjective","company.catchPhraseDescriptor","company.catchPhraseNoun","company.bsAdjective","company.bsBuzz","company.bsNoun","address.streetSuffix","address.county","address.country","address.state","finance.accountName","finance.transactionType","finance.currencyName","hacker.noun","hacker.verb","hacker.adjective","hacker.ingverb","hacker.abbreviation","name.jobDescriptor","name.jobArea","name.jobType"],m=c.random.arrayElement(t),d=c.fake("{{"+m+"}}");return c.random.arrayElement(d.split(" "))},this.words=function(a){var t=[];typeof a=="undefined"&&(a=c.datatype.number({min:1,max:3}));for(var m=0;m<a;m++)t.push(c.random.word());return t.join(" ")},this.image=function(){return c.image.image()},this.locale=function(){return c.random.arrayElement(Object.keys(c.locales))},this.alpha=function(a){typeof a=="undefined"?a={count:1}:typeof a=="number"?a={count:a}:typeof a.count=="undefined"&&(a.count=1),typeof a.upcase=="undefined"&&(a.upcase=!1),typeof a.bannedChars=="undefined"&&(a.bannedChars=[]);var t="",m=["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"];a.bannedChars&&(m=o(m,a.bannedChars));for(var d=0;d<a.count;d++)t+=c.random.arrayElement(m);return a.upcase?t.toUpperCase():t},this.alphaNumeric=function(a,t){typeof a=="undefined"&&(a=1),typeof t=="undefined"&&(t={}),typeof t.bannedChars=="undefined"&&(t.bannedChars=[]);var m="",d=["0","1","2","3","4","5","6","7","8","9","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"];t&&t.bannedChars&&(d=o(d,t.bannedChars));for(var h=0;h<a;h++)m+=c.random.arrayElement(d);return m},this.hexaDecimal=function(a){return console.log("Deprecation Warning: faker.random.hexaDecimal is now located in faker.datatype.hexaDecimal"),c.datatype.hexaDecimal(a)},this}u.exports=e})(T);var B=T.exports,C={exports:{}};(function(u){var o=function(e){var c=this;return c.randomize=function(n){return n=n||["a","b","c"],e.random.arrayElement(n)},c.slugify=function(n){return n=n||"",n.replace(/ /g,"-").replace(/[^\一-龠\ぁ-ゔ\ァ-ヴー\w\.\-]+/g,"")},c.replaceSymbolWithNumber=function(n,r){n=n||"",r===void 0&&(r="#");for(var a="",t=0;t<n.length;t++)n.charAt(t)==r?a+=e.datatype.number(9):n.charAt(t)=="!"?a+=e.datatype.number({min:2,max:9}):a+=n.charAt(t);return a},c.replaceSymbols=function(n){n=n||"";for(var r=["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"],a="",t=0;t<n.length;t++)n.charAt(t)=="#"?a+=e.datatype.number(9):n.charAt(t)=="?"?a+=e.random.arrayElement(r):n.charAt(t)=="*"?a+=e.datatype.boolean()?e.random.arrayElement(r):e.datatype.number(9):a+=n.charAt(t);return a},c.replaceCreditCardSymbols=function(n,r){n=n||"6453-####-####-####-###L",r=r||"#";var a=function(d){d.reverse(),d=d.map(function(f,i){return i%2==0&&(f*=2,f>9&&(f-=9)),f});var h=d.reduce(function(f,i){return f+i});return h%10};n=e.helpers.regexpStyleStringParse(n),n=e.helpers.replaceSymbolWithNumber(n,r);var t=n.replace(/\D/g,"").split("").map(function(d){return parseInt(d)}),m=a(t);return n.replace("L",m)},c.repeatString=function(n,r){typeof r=="undefined"&&(r=0);for(var a="",t=0;t<r;t++)a+=n.toString();return a},c.regexpStyleStringParse=function(n){n=n||"";for(var r=/(.)\{(\d+)\,(\d+)\}/,a=/(.)\{(\d+)\}/,t=/\[(\d+)\-(\d+)\]/,m,d,h,f,i=n.match(r);i!==null;)m=parseInt(i[2]),d=parseInt(i[3]),m>d&&(h=d,d=m,m=h),f=e.datatype.number({min:m,max:d}),n=n.slice(0,i.index)+e.helpers.repeatString(i[1],f)+n.slice(i.index+i[0].length),i=n.match(r);for(i=n.match(a);i!==null;)f=parseInt(i[2]),n=n.slice(0,i.index)+e.helpers.repeatString(i[1],f)+n.slice(i.index+i[0].length),i=n.match(a);for(i=n.match(t);i!==null;)m=parseInt(i[1]),d=parseInt(i[2]),m>d&&(h=d,d=m,m=h),n=n.slice(0,i.index)+e.datatype.number({min:m,max:d}).toString()+n.slice(i.index+i[0].length),i=n.match(t);return n},c.shuffle=function(n){if(typeof n=="undefined"||n.length===0)return n||[];n=n||["a","b","c"];for(var r,a,t=n.length-1;t>0;--t)a=e.datatype.number(t),r=n[t],n[t]=n[a],n[a]=r;return n},c.mustache=function(n,r){if(typeof n=="undefined")return"";for(var a in r){var t=new RegExp("{{"+a+"}}","g");n=n.replace(t,r[a])}return n},c.createCard=function(){return{name:e.name.findName(),username:e.internet.userName(),email:e.internet.email(),address:{streetA:e.address.streetName(),streetB:e.address.streetAddress(),streetC:e.address.streetAddress(!0),streetD:e.address.secondaryAddress(),city:e.address.city(),state:e.address.state(),country:e.address.country(),zipcode:e.address.zipCode(),geo:{lat:e.address.latitude(),lng:e.address.longitude()}},phone:e.phone.phoneNumber(),website:e.internet.domainName(),company:{name:e.company.companyName(),catchPhrase:e.company.catchPhrase(),bs:e.company.bs()},posts:[{words:e.lorem.words(),sentence:e.lorem.sentence(),sentences:e.lorem.sentences(),paragraph:e.lorem.paragraph()},{words:e.lorem.words(),sentence:e.lorem.sentence(),sentences:e.lorem.sentences(),paragraph:e.lorem.paragraph()},{words:e.lorem.words(),sentence:e.lorem.sentence(),sentences:e.lorem.sentences(),paragraph:e.lorem.paragraph()}],accountHistory:[e.helpers.createTransaction(),e.helpers.createTransaction(),e.helpers.createTransaction()]}},c.contextualCard=function(){var n=e.name.firstName(),r=e.internet.userName(n);return{name:n,username:r,avatar:e.internet.avatar(),email:e.internet.email(r),dob:e.date.past(50,new Date("Sat Sep 20 1992 21:35:02 GMT+0200 (CEST)")),phone:e.phone.phoneNumber(),address:{street:e.address.streetName(!0),suite:e.address.secondaryAddress(),city:e.address.city(),zipcode:e.address.zipCode(),geo:{lat:e.address.latitude(),lng:e.address.longitude()}},website:e.internet.domainName(),company:{name:e.company.companyName(),catchPhrase:e.company.catchPhrase(),bs:e.company.bs()}}},c.userCard=function(){return{name:e.name.findName(),username:e.internet.userName(),email:e.internet.email(),address:{street:e.address.streetName(!0),suite:e.address.secondaryAddress(),city:e.address.city(),zipcode:e.address.zipCode(),geo:{lat:e.address.latitude(),lng:e.address.longitude()}},phone:e.phone.phoneNumber(),website:e.internet.domainName(),company:{name:e.company.companyName(),catchPhrase:e.company.catchPhrase(),bs:e.company.bs()}}},c.createTransaction=function(){return{amount:e.finance.amount(),date:new Date(2012,1,2),business:e.company.companyName(),name:[e.finance.accountName(),e.finance.mask()].join(" "),type:c.randomize(e.definitions.finance.transaction_type),account:e.finance.account()}},c};u.exports=o})(C);var G=C.exports;function W(u){var o=this;u=u||{};var e=o.locales||u.locales||{},c=o.locale||u.locale||"en",n=o.localeFallback||u.localeFallback||"en";o.locales=e,o.locale=c,o.localeFallback=n,o.definitions={},o.unique=new j(o).unique,o.mersenne=new _,o.random=new B(o),o.helpers=new G(o),o.datatype=new b(o)}var g=new W({locale:"en",localeFallback:"en"});g.locales.en={};const L=["Alicorn","Banshee","Basilisk","Bigfoot","Black Dog","Black Eyed Being","Bogeyman","Bogle","Bray Road Beast","Brownie","Centaur","Cerberus","Charybdis","Chimera","Cockatrice","Cyclops","Cynocephalus","Demon","Doppelganger","Dragon","Dwarf","Echidna","Elf","Fairy","Ghost","Gnome","Goblin","Golem","Gorgon","Griffin","Grim Reaper","Hobgoblin","Hydra","Imp","Ladon","Leprechaun","Loch Ness Monster","Manticore","Medusa","Mermaid","Minotaur","Mothman","Mutant","Nemean Lion","New Jersey Devil","Nymph","Ogre","Orthros","Pegasus","Phoenix","Pixie","Sasquatch","Satyr","Scylla","Sea Monster","Sea-Goat","Shade","Shapeshifter","Siren","Sphinx","Sprite","Sylph","Thunderbird","Typhon","Unicorn","Valkyrie","Vampire","Wendigo","Will-o'-the-wisp","Werewolf","Wraith","Zombie"];var S={exports:{}};(function(u){u.exports=["red","green","blue","yellow","purple","mint green","teal","white","black","orange","pink","grey","maroon","violet","turquoise","tan","sky blue","salmon","plum","orchid","olive","magenta","lime","ivory","indigo","gold","fuchsia","cyan","azure","lavender","silver"]})(S);var z=S.exports;function F(){const u=g.random.arrayElement(z).replace(/\s/g,"-").toLowerCase(),o=g.random.arrayElement(L).replace(/\s/g,"-").toLowerCase();return u+"-"+o}function O(){return g.unique(F,null,{maxTime:500})}return O});