Skip to content
Source
Sign inSign up
Open History to see the last commit

loadFileAncestors.ts

15 lines563 Bytes

1/** The loader owns deduplication and the shared request cap, including other tree loads. */
2export async function loadFileAncestors(
3 selectedPath: string,
4 load: (directoryPath: string) => Promise<void>,
5 options: { readonly signal: AbortSignal },
6) {
7 const segments = selectedPath.split("/");
8 let next = 0;
9 const worker = async () => {
10 while (next < segments.length && !options.signal.aborted) {
11 await load(segments.slice(0, next++).join("/"));
12 }
13 };
14 await Promise.all(Array.from({ length: Math.min(4, segments.length) }, worker));