LR2Hook Converter and Parser definitions

This commit is contained in:
zkldi
2021-12-10 18:24:28 +00:00
parent 4bf39da0be
commit c30c5e2dbc
12 changed files with 363 additions and 6 deletions
+10 -1
View File
@@ -37,7 +37,7 @@ export function MStoS(ms: number) {
/**
* Random From Array - Selects a random value from an array.
*/
export function RFA(arr: unknown[]) {
export function RFA<T>(arr: T[]): T {
return arr[Math.floor(Math.random() * arr.length)];
}
@@ -133,3 +133,12 @@ export function Sleep(ms: number) {
export function GetTimeXHoursAgo(hours: integer) {
return Date.now() - ONE_HOUR * hours;
}
export function ApplyNTimes<T>(n: integer, fn: (i: integer) => T): T[] {
const arr = [];
for (let i = 0; i < n; i++) {
arr.push(fn(i));
}
return arr;
}