-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
36 lines (26 loc) · 927 Bytes
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
async function main() {
const {Prng} = await import( "./pringle.js" );
const prng = new Prng(20);
console.log('Return random number between 0 and 1');
console.log(prng.rand());
console.log('Return random number between 0 and 50');
console.log(prng.rand(50));
console.log('Return random number between 30 and 40');
console.log(prng.rand(30, 40));
console.log('Iterate over random numbers until count of 5 is reached');
let count = 5;
for (const r of prng) {
console.log(r);
if (count-- == 0) {
break;
}
}
console.log('Use the iterator to loop over 5 random numbers');
for (const r of prng.iter(5)) {
console.log(r);
}
console.log('Use the iterator to generate an array of 5 random integers between 0 and 10');
const arr = Array.from(prng.iter(5), (r) => Math.floor(r * 10));
console.log(arr);
}
main();