-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.min.js
2 lines (2 loc) · 2.78 KB
/
script.min.js
1
2
/*! https://github.com/AspieSoft/random-number-js v1.3.2 | (c) [email protected] */
const random=function(){const t={liteMode:!1,avoidRadius:0};let o=[];function r(e,a,n=null,l=!1){if(e=Number(e),a=Number(a),e===NaN||a===NaN)return NaN;if(e>a){let t=e;e=a,a=t}if(e===a)return e;if(e+1===a)return Math.floor(10*Math.random())%2==0?e:a;let f=(new Date).getTime().toString().slice(-10),i=Math.max(Math.abs(a).toString().length,Math.abs(e).toString().length),h=Math.pow(10,i),M="";for(;M.length<i&&(M+=f[Math.floor(10*Math.random())],Math.floor(Math.random()*h)%2!=0||Math.floor(Math.random()*h)%2!=0););let d=Math.pow(10,M.length);M=M.split("");for(let t=0;t<M.length;t++){let o=Math.floor(10*Math.random()),r=Math.floor(Math.random()*d),e=Math.floor(Math.random()*d);(o%2==0&&r%2==0&&e%2==0||o%2!=0&&(r%2==0&&e%2!=0||r%2!=0&&e%2==0))&&(M[t]=Math.floor(10*Math.random()).toString())}if(Math.floor(100*Math.random())%2==0&&M.reverse(),l&&"0"===M[0]&&(M[0]="1"),M=M.length>0?Number(M.join("")):0,(e<0&&a<0||(e<0||a<0)&&Math.floor(100*Math.random())%2==0)&&(M*=-1),a>0)for(;M>a;)M-=a-1;else if(a<0)for(;M>a;)M+=a-1;else if(0===a&&M>0)return r(e,a,n);if(e>0)for(;M<e;)M+=e+1;else if(e<0)for(;M<e;)M-=e+1;else if(0===e&&M<0)return r(e,a,n);if(a>0)for(;M>a;)M-=e-1;else if(a<0)for(;M>a;)M+=e-1;else if(0===a&&M>0)return r(e,a,n);if(M<e||M>a)return r(e,a,n);if(n||!1!==n&&t.liteMode)return M;let u=[...o];if(0!==t.avoidRadius)for(let l=0;l<u.length;l++)if(u[l]>=M-t.avoidRadius&&u[l]<=M+t.avoidRadius&&(Math.floor(100*Math.random())%3==0&&Math.floor(100*Math.random())%3==0&&o.splice(l,1),Math.floor(100*Math.random())%2==0))return o.splice(l,1),r(e,a,n);for(;u.includes(M);)if(Math.floor(100*Math.random())%2==0&&u.splice(u.indexOf(M),1),Math.floor(100*Math.random())%2==0&&Math.floor(100*Math.random())%2==0&&o.splice(o.indexOf(M),1),Math.floor(100*Math.random())%2==0||Math.floor(100*Math.random())%2==0)return r(e,a,n);return o.push(M),M}let e=!0,a=setInterval((function(){o=[]}),1e3);const n=function(t=0,o=100,e=0,a=null){if(t=Number(t),o=Number(o),e=Number(e),t===NaN||o===NaN||e===NaN)return"NaN";if(t>o){let r=t;t=o,o=r}let n=Math.floor(e);n!==e&&n++,n<0&&(n*=-1),e<0&&(e=Math.floor(10*Math.random()));let l=r(t,o,a,!1);if(l<t||l>=o||0==e)return l;let f=Math.pow(10,n);if(Math.floor(100*Math.random())%2==0||Math.floor(100*Math.random())%2==0){let t=r(0,f-1,a,!0);for(t=t.toString();t.length<n&&Math.floor(100*Math.random())%2==0;)t="0"+t;t=Number("0."+t),l+=t}return Math.round(l*f)/f};return n.setLiteMode=function(o=!0){t.liteMode=!!o,t.liteMode?n.setClearInterval(0):e||n.setClearInterval()},n.setAvoidRadius=function(o=0){t.avoidRadius=Number(o)||0},n.setClearInterval=function(t=1e3){clearInterval(a),t&&"number"==typeof t&&t>0?(e=!0,a=setInterval((function(){o=[]}),t)):e=!1},n}();"object"==typeof module&&(module.exports=random);