mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 02:12:26 +00:00
fix(ci): reduce channelProfile.js size and bound relay concurrency
- Refactored `js/channelProfile.js` to use `pMapSettled` from `js/utils/asyncUtils.js`, fixing both the concurrency issue (P1) and the file size lint failure. - `pMapSettled` replaces a bulky inline `pMap` wrapper, reducing code volume. - Ensures `js/channelProfile.js` stays within its grandfathered line count limit (5579 lines). Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
575c169be6
commit
004c0bed83
2 files changed
+28
-11
No files matched your search
@@ -54,6 +54,31 @@ export async function pMap(iterable, mapper, { concurrency = Infinity } = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to pMap, but returns { status: 'fulfilled', value } or { status: 'rejected', reason }
|
||||
* for each item, ensuring all items are processed (like Promise.allSettled).
|
||||
*
|
||||
* @param {Iterable} iterable - The items to map over.
|
||||
* @param {Function} mapper - The async mapping function.
|
||||
* @param {Object} options - Options object.
|
||||
* @param {number} options.concurrency - The concurrency limit (default: Infinity).
|
||||
* @returns {Promise<Array>} - The settled results.
|
||||
*/
|
||||
export async function pMapSettled(iterable, mapper, options) {
|
||||
return pMap(
|
||||
iterable,
|
||||
async (item, index) => {
|
||||
try {
|
||||
const value = await mapper(item, index);
|
||||
return { status: "fulfilled", value };
|
||||
} catch (reason) {
|
||||
return { status: "rejected", reason };
|
||||
}
|
||||
},
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
export function withRequestTimeout(promise, timeoutMs, onTimeout, message = "Request timed out") {
|
||||
const resolvedTimeout = Number(timeoutMs);
|
||||
const effectiveTimeout =
|
||||
|
||||
Reference in new issue
Block a user