cdkey
Version:
Generate random strings by template.
1 lines • 6.31 kB
JavaScript
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";(function(t){var n="object"==typeof t&&t&&t.Object===Object&&t;e.a=n}).call(this,n(2))},,function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e);var r=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},o=n(0),u="object"==typeof self&&self&&self.Object===Object&&self,i=(o.a||u||Function("return this")()).Symbol,a=Object.prototype,c=a.hasOwnProperty,l=a.toString,f=i?i.toStringTag:void 0;var s=function(t){var e=c.call(t,f),n=t[f];try{t[f]=void 0;var r=!0}catch(t){}var o=l.call(t);return r&&(e?t[f]=n:delete t[f]),o},h=Object.prototype.toString;var d=function(t){return h.call(t)},p="[object Null]",b="[object Undefined]",g=i?i.toStringTag:void 0;var y=function(t){return null==t?void 0===t?b:p:g&&g in Object(t)?s(t):d(t)};var v=function(t){return null!=t&&"object"==typeof t},m="[object Symbol]";var _=function(t){return"symbol"==typeof t||v(t)&&y(t)==m},x=NaN,j=/^\s+|\s+$/g,O=/^[-+]0x[0-9a-f]+$/i,X=/^0b[01]+$/i,M=/^0o[0-7]+$/i,w=parseInt;var P=function(t){if("number"==typeof t)return t;if(_(t))return x;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(j,"");var n=X.test(t);return n||M.test(t)?w(t.slice(2),n?2:8):O.test(t)?x:+t},S=1/0,A=1.7976931348623157e308;var E=function(t){return t?(t=P(t))===S||t===-S?(t<0?-1:1)*A:t==t?t:0:0===t?t:0};var F=function(t){var e=E(t),n=e%1;return e==e?n?e-n:e:0};var I=function(t){return"number"==typeof t&&t==F(t)};const U="0123456789",N="abcdefghijklmnopqrstuvwxyz",R=N.toUpperCase(),T=R+N,C=U+T,L=new RegExp("[0O1Il]","g"),$=U.replace(L,""),B=R.replace(L,""),k=N.replace(L,"");var D={0:$,A:B,a:k,X:$+B,x:$+k,"?":$+B+k},H=Math.floor,q=Math.random;var z=function(t,e){return t+H(q()*(e-t+1))};var G=function(t,e){return t===e||t!=t&&e!=e},W="[object AsyncFunction]",J="[object Function]",K="[object GeneratorFunction]",Q="[object Proxy]";var V=function(t){if(!r(t))return!1;var e=y(t);return e==J||e==K||e==W||e==Q},Y=9007199254740991;var Z=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Y};var tt=function(t){return null!=t&&Z(t.length)&&!V(t)},et=9007199254740991,nt=/^(?:0|[1-9]\d*)$/;var rt=function(t,e){var n=typeof t;return!!(e=null==e?et:e)&&("number"==n||"symbol"!=n&&nt.test(t))&&t>-1&&t%1==0&&t<e};var ot=function(t,e,n){if(!r(n))return!1;var o=typeof e;return!!("number"==o?tt(n)&&rt(e,n.length):"string"==o&&e in n)&&G(n[e],t)},ut=parseFloat,it=Math.min,at=Math.random;var ct=function(t,e,n){if(n&&"boolean"!=typeof n&&ot(t,e,n)&&(e=n=void 0),void 0===n&&("boolean"==typeof e?(n=e,e=void 0):"boolean"==typeof t&&(n=t,t=void 0)),void 0===t&&void 0===e?(t=0,e=1):(t=E(t),void 0===e?(e=t,t=0):e=E(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var o=at();return it(t+o*(e-t+ut("1e-"+((o+"").length-1))),e)}return z(t,e)};class lt{constructor(t){return this._amount=1,this._debug=!1,this._repeat=!1,t&&(t.amount&&(this._amount=t.amount),t.length&&(this._length=t.length),t.char&&(this._char=t.char),t.template&&(this._template=t.template),t.syntax&&(this._syntax=t.syntax),t.debug&&(this._debug=t.debug)),this}get debug(){return this._debug}set debug(t){this._debug=t}length(t){return this._length=t,this}char(t){return this._char=t,this}template(t){return this._template=t,this}syntax(t){return this._syntax=t,this}amount(t){return this._amount=t,this}generate(){return this.gen()}gen(){let t=[],e=()=>"";this._length&&this._length>0?e=(()=>(function(t,e){let n="";for(let r=0;r<e;r++)n+=t.charAt(Math.floor(Math.random()*t.length));return n})(this._char,this._length)):this._template&&(e=(()=>(function(t,e){let n="";for(let o=0;o<t.length;o++){const u=e[t[o]];n+=u?(r=u)[ct(0,r.length-1)]:t[o]}var r;return n})(this._template,this._syntax)));let n=0;for(let r=0;r<this._amount;r++){let o=e();if(-1===t.indexOf(o))t.push(o);else{if(++n>1e3){console.error("Ignored too many duplicate result, please decrease amount.");break}r--}}return this._amount<=1?(this._debug&&this._debug(t[0]),t[0]):(this._debug&&this._debug(t),t)}}const ft={length:32,char:U},st=ft,ht={length:32,char:"0123456789ABCDEF"},dt={length:32,char:N},pt={length:32,char:R},bt={length:32,char:T},gt={length:32,char:C},yt={template:"????-????-????-????",syntax:D},vt={template:"XXXX-XXXX-XXXX-XXXX",syntax:D};function mt(t,e,n){let o,u,i,a,c;if(0===arguments.length);else{if(!0===t)return new lt;I(t)?(u=t,e&&(i=e)):r(t)?(o={...t},e&&(u=e,n&&(I(n)?i=n:a=n))):(a=t,e&&(r(e)?(c={...e},n&&(u=n)):(u=e,n&&(c={...n}))))}return o||(o={...yt,syntax:{...yt.syntax}}),u&&(o.amount=u),a&&(o.length=null,o.char=null,o.template=a,c?o.syntax={...D,...c}:o.syntax||(o.syntax={...yt.syntax})),i&&(o.template=null,o.syntax=null,o.length=i,o.char||(o.char=yt.syntax["?"])),new lt(o).gen()}function _t(){return D}function xt(t){return new lt(t)}n.d(e,"cdkey",function(){return mt}),n.d(e,"syntax",function(){return _t}),n.d(e,"create",function(){return xt}),n.d(e,"NUMERIC",function(){return ft}),n.d(e,"NUMBER",function(){return st}),n.d(e,"HEX",function(){return ht}),n.d(e,"LOWER",function(){return dt}),n.d(e,"UPPER",function(){return pt}),n.d(e,"ALPHABETIC",function(){return bt}),n.d(e,"ALPHANUMERIC",function(){return gt}),n.d(e,"DEFAULT",function(){return yt}),n.d(e,"DIABLO",function(){return vt});e.default=mt}]);