Skip to content
Snippets Groups Projects
Commit a4432b8e authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

Merge branch 'MONSTER/INIT/a2f41565-779f-4abc-8642-fa936302659f' into 'master'

Monster/init/a2f41565 779f 4abc 8642 fa936302659f

See merge request oss/libraries/javascript/monster!1
parents 474d8aff fbbea27a
No related branches found
No related tags found
No related merge requests found
Showing
with 29343 additions and 0 deletions
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/** Monster 1.0.14, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
'use strict';
/** Monster 1.0.14, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
'use strict';import{Monster}from"../namespace.js";function random(min,max){if(min===undefined){min=0}if(max===undefined){max=MAX}if(max<min){throw new Error("max must be greater than min")}return Math.round(create(min,max))}var MAX=1000000000;Math.log2=Math.log2||function(n){return Math.log(n)/Math.log(2)};function create(min,max){var crypt;if(typeof global!=="undefined"){crypt=global?.["crypto"]||global?.["msCrypto"]}else{crypt=typeof crypto!=="undefined"?crypto:undefined}if(typeof crypt==="undefined"){throw new Error("missing crypt")}let rval=0;const range=max-min;if(range<2){return min}const bitsNeeded=Math.ceil(Math.log2(range));if(bitsNeeded>53){throw new Error("we cannot generate numbers larger than 53 bits.")}const bytesNeeded=Math.ceil(bitsNeeded/8);const mask=Math.pow(2,bitsNeeded)-1;const byteArray=new Uint8Array(bytesNeeded);crypt.getRandomValues(byteArray);let p=(bytesNeeded-1)*8;for(var i=0;i<bytesNeeded;i++){rval+=byteArray[i]*Math.pow(2,p);p-=8}rval=rval&mask;if(rval>=range){return create(min,max)}return min+rval}Monster.assignToNamespace("Monster.Math",random);export{Monster,random};
/** Monster 1.0.14, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
'use strict';
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment