UNPKG

sensai

Version:

Because even AI needs a master

34 lines (33 loc) 999 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "default", { enumerable: true, get: function() { return _default; } }); const _promises = require("node:fs/promises"); const _nodepath = require("node:path"); /** * Recursively walk a directory and stream route files with applicable middlewares * All paths are normalized to POSIX format as it is what's used for URIs. * * @todo TODO stop propagration on slot folders */ const walk = async function*(dir) { const entries = await (0, _promises.readdir)(dir, { withFileTypes: true }); // Process all entries in a single pass for (const entry of entries){ const { name } = entry; const path = (0, _nodepath.join)(dir, name); if (entry.isDirectory()) { yield* walk(path); } else { yield _nodepath.posix.join("/", ...path.split(_nodepath.sep)); } } }; const _default = walk;