number-generator
Version:
Generate repeatable pseudo random numbers and non-cryptographic hash numbers for usage in Node.js and browser environments.
3 lines (2 loc) • 739 B
JavaScript
;var e,t,n=(e=Math.pow(2,-32),t=Math.pow(2,32),function(n){var r=1,u=0,o=0,c=0;function i(t){return function(e){if(e%1!=0||e<=0)throw new TypeError('Expected seed to be an unsigned integer greater or equal 1, but got "'.concat(e,'"'))}(t),u=(t>>>0)*e,o=(t=69069*t+1>>>0)*e,c=(t=69069*t+1>>>0)*e,r=1,t}function s(){var t=2091639*u+r*e;return u=o,o=c,c=t-(r=0|t)}return i(void 0===n?1:n),{setSeed:i,uFloat32:s,uInt32:function(){return s()*t>>>0},getState:function(){return{correction:r,sequence:[u,o,c]}},setState:function(e){(e=e||{correction:1,sequence:[0,0,0]}).sequence=e.sequence||[],r=e.correction||1,u=e.sequence[0]||0,o=e.sequence[1]||0,c=e.sequence[2]||0}}});module.exports=n;
//# sourceMappingURL=aleaRNGFactory.js.map