The repo is already named cmjs, so the nested cmjs/ subfolder was redundant. Moved css/, js/, strings/, templates/, and the gitignored articles/ up to the repo root and removed the empty cmjs/ directory, so the whole repo (or just css/js/strings/templates/articles) can be dropped into an existing site and embedded as-is — no wrapper folder required. This also fixes a real bug: js/config.js's MARKED_URL previously reached outside cmjs/ (../../js/marked.min.js) to find the vendored marked.min.js, which already lived at the repo root as a sibling of cmjs/ rather than inside it. Now that both files sit in the same js/ folder, MARKED_URL is a same-directory reference and no longer depends on anything outside this one folder tree. BASE_URL's own formula is unchanged (config.js is still exactly one level below whatever holds articles/, strings/, and templates/ — previously that was cmjs/, now it's the repo root). Updated index.html, .gitignore (/cmjs/articles/ -> /articles/), and every path reference throughout README.md (project structure diagram, embedding instructions, nginx config, discovery/caching docs) to match. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXSVPS3UmmASiiprPfcnUd
16 lines
638 B
JavaScript
16 lines
638 B
JavaScript
// Runs `fn` over `items` with at most `limit` calls in flight at once.
|
|
// A worker-pool: each worker pulls the next index off a shared cursor until
|
|
// the list is exhausted, so slow items don't stall workers behind them.
|
|
export async function mapWithConcurrency(items, limit, fn) {
|
|
const results = new Array(items.length);
|
|
let cursor = 0;
|
|
async function worker() {
|
|
while (cursor < items.length) {
|
|
const index = cursor++;
|
|
results[index] = await fn(items[index], index);
|
|
}
|
|
}
|
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
return results;
|
|
}
|