Refactor to use ES2024+ features for Node 24

Use Set for O(1) redirect status code lookup in fetch.ts

Use at(-1) and Object.hasOwn() in tools.ts

Use for...of with entries() in utils.ts
This commit is contained in:
Shivam Mathur
2026-01-20 06:46:28 +05:30
parent f0e37f9e90
commit 871ff01b2b
4 changed files with 12 additions and 11 deletions

View File

@@ -97,9 +97,8 @@ export async function parseIniFile(ini_file: string): Promise<string> {
}
/**
* Async foreach loop
* Async foreach loop using modern for...of pattern
*
* @author https://github.com/Atinux
* @param array
* @param callback
*/
@@ -111,8 +110,8 @@ export async function asyncForEach(
array: Array<string>
) => Promise<void>
): Promise<void> {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
for (const [index, element] of array.entries()) {
await callback(element, index, array);
}
}