mirror of
https://notabug.org/SuperSaltyGamer/ame
synced 2026-01-16 16:52:56 -03:00
14 lines
374 B
TypeScript
14 lines
374 B
TypeScript
import { join } from "path";
|
|
import { readdir } from "fs/promises";
|
|
|
|
// Walks a directory tree starting from path.
|
|
export async function* walk(path: string): AsyncGenerator<string> {
|
|
for (const entry of await readdir(path, { withFileTypes: true })) {
|
|
if (entry.isDirectory()) {
|
|
yield* walk(join(path, entry.name));
|
|
} else {
|
|
yield join(path, entry.name);
|
|
}
|
|
}
|
|
}
|