(from=null,to=null,interpolation=null)
| 1 | export function random(from=null,to=null,interpolation=null){ |
| 2 | if(from==null){ |
| 3 | from=0; |
| 4 | to=1; |
| 5 | }else if(from!=null && to==null){ |
| 6 | to=from; |
| 7 | from=0; |
| 8 | } |
| 9 | const delta=to-from; |
| 10 | |
| 11 | if(interpolation==null){ |
| 12 | interpolation=(n)=>{ |
| 13 | return n; |
| 14 | } |
| 15 | } |
| 16 | return from+(interpolation(Math.random())*delta); |
| 17 | } |
| 18 | export function chance(c){ |
| 19 | return random()<=c; |
| 20 | } |
no outgoing calls
no test coverage detected