Add settings page for managing forecasting API key and URL via UI
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cae411eae7
commit
1c411e402e
19809 changed files with 1962608 additions and 97 deletions
46
frontend/node_modules/es-toolkit/dist/array/limitAsync.js
generated
vendored
Normal file
46
frontend/node_modules/es-toolkit/dist/array/limitAsync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
const require_semaphore = require("../promise/semaphore.js");
|
||||
//#region src/array/limitAsync.ts
|
||||
/**
|
||||
* Wraps an async function to limit the number of concurrent executions.
|
||||
*
|
||||
* This function creates a wrapper around an async callback that ensures at most
|
||||
* `concurrency` number of executions can run simultaneously. Additional calls will
|
||||
* wait until a slot becomes available.
|
||||
*
|
||||
* @template F - The type of the async function to wrap.
|
||||
* @param callback The async function to wrap with concurrency control.
|
||||
* @param concurrency Maximum number of concurrent executions allowed.
|
||||
* @returns A wrapped version of the callback with concurrency limiting.
|
||||
* @example
|
||||
* const limitedFetch = limitAsync(async (url) => {
|
||||
* return await fetch(url);
|
||||
* }, 3);
|
||||
*
|
||||
* // Only 3 fetches will run concurrently
|
||||
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5'];
|
||||
* await Promise.all(urls.map(url => limitedFetch(url)));
|
||||
*
|
||||
* @example
|
||||
* const processItem = async (item) => {
|
||||
* // Expensive async operation
|
||||
* return await heavyComputation(item);
|
||||
* };
|
||||
*
|
||||
* const limitedProcess = limitAsync(processItem, 2);
|
||||
* const items = [1, 2, 3, 4, 5];
|
||||
* // At most 2 items will be processed concurrently
|
||||
* await Promise.all(items.map(item => limitedProcess(item)));
|
||||
*/
|
||||
function limitAsync(callback, concurrency) {
|
||||
const semaphore = new require_semaphore.Semaphore(concurrency);
|
||||
return async function(...args) {
|
||||
try {
|
||||
await semaphore.acquire();
|
||||
return await callback.apply(this, args);
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
exports.limitAsync = limitAsync;
|
||||
Loading…
Add table
Add a link
Reference in a new issue