Linted code.
This commit is contained in:
1 parent
d12600348f
commit
eae420a5a4
8 files changed
+200
-214
No files matched your search
+42
-40
@@ -1,22 +1,25 @@
|
||||
|
||||
export function* randomNumbers(seed: number, max: number, maxResult: number|undefined = undefined) : Generator<number> {
|
||||
export function* randomNumbers(
|
||||
seed: number,
|
||||
max: number,
|
||||
maxResult: number | undefined = undefined,
|
||||
): Generator<number> {
|
||||
const a = 48271;
|
||||
const m = 2147483647;
|
||||
const m = 2147483647;
|
||||
max = Math.floor(max);
|
||||
let i = 0;
|
||||
while (true) {
|
||||
seed = (a * seed) % m;
|
||||
seed = (a * seed) % m;
|
||||
yield seed % max;
|
||||
i ++;
|
||||
if(maxResult !== undefined && i >= maxResult){
|
||||
return;
|
||||
i++;
|
||||
if (maxResult !== undefined && i >= maxResult) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function range(min: number, max: number): number[]{
|
||||
const ret = []
|
||||
for(let i = min; i < max; i ++){
|
||||
export function range(min: number, max: number): number[] {
|
||||
const ret = [];
|
||||
for (let i = min; i < max; i++) {
|
||||
ret.push(i);
|
||||
}
|
||||
return ret;
|
||||
@@ -24,37 +27,36 @@ export function range(min: number, max: number): number[]{
|
||||
|
||||
export function generateLargeText(seed: number, size: number): string {
|
||||
const words = [
|
||||
"Norway",
|
||||
"Germany",
|
||||
"Ecuador",
|
||||
"Chile",
|
||||
"Colombia",
|
||||
"Sri Lanka",
|
||||
"Guinea",
|
||||
"United Kingdom",
|
||||
"Egypt",
|
||||
"Palau",
|
||||
"Latvia",
|
||||
"Congo, Democratic Republic of the",
|
||||
"Malawi",
|
||||
"Senegal",
|
||||
"Trinidad and Tobago",
|
||||
"Guatemala",
|
||||
"Chad",
|
||||
"New Zealand",
|
||||
"Malaysia",
|
||||
"Lithuania",
|
||||
"Taiwan",
|
||||
"Solomon Islands",
|
||||
"Grenada",
|
||||
"Hungary",
|
||||
"Korea, South",
|
||||
'Norway',
|
||||
'Germany',
|
||||
'Ecuador',
|
||||
'Chile',
|
||||
'Colombia',
|
||||
'Sri Lanka',
|
||||
'Guinea',
|
||||
'United Kingdom',
|
||||
'Egypt',
|
||||
'Palau',
|
||||
'Latvia',
|
||||
'Congo, Democratic Republic of the',
|
||||
'Malawi',
|
||||
'Senegal',
|
||||
'Trinidad and Tobago',
|
||||
'Guatemala',
|
||||
'Chad',
|
||||
'New Zealand',
|
||||
'Malaysia',
|
||||
'Lithuania',
|
||||
'Taiwan',
|
||||
'Solomon Islands',
|
||||
'Grenada',
|
||||
'Hungary',
|
||||
'Korea, South',
|
||||
];
|
||||
let ret: string[] = [];
|
||||
for (let i = 0; i < size; i++) {
|
||||
seed = (seed * 4931 + 2753) % words.length;
|
||||
ret.push(words[seed]);
|
||||
seed = (seed * 4931 + 2753) % words.length;
|
||||
ret.push(words[seed]);
|
||||
}
|
||||
return ret.join(" ");
|
||||
}
|
||||
|
||||
return ret.join(' ');
|
||||
}
|
||||
Reference in new issue
Block a user