Added a very complicated AsyncIterableReader class.

The class was already implemented in
"https://deno.land/std@0.144.0/streams/conversion.ts".  So, I litterally
lost 1 day of work!  I hate myself.
This commit is contained in:
didier amyot committed 2023-06-12 12:02:15 -04:00
1 parent 17a1b4bed3
commit 0d627c9051
125 files changed
+26943 -83

No files matched your search

+6 -1
View File
@@ -1,12 +1,17 @@
export function* randomNumbers(seed: number, max: number) : Generator<number> {
export function* randomNumbers(seed: number, max: number, maxResult: number|undefined = undefined) : Generator<number> {
const a = 48271;
const m = 2147483647;
max = Math.floor(max);
let i = 0;
while (true) {
seed = (a * seed) % m;
yield seed % max;
i ++;
if(maxResult !== undefined && i >= maxResult){
return;
}
}
}