pathsContinuing(typed: string,cwd: string): string[]
Every path that continues typed, spelled the way it was — directories with a trailing slash.
Hidden entries only once a dot has been typed, which is the rule every shell uses and the reason
.cat does not open with a list of dotfiles. That rule is about what was TYPED, so it is
decided once rather than re-asked for every entry in the directory.
One pass. This used to filter twice and then map, walking the entries three times and allocating an array each time; the listing it does first costs five times all of that put together, so the saving is small — but the two-filter shape was also hiding the loop-invariant above.
import { pathsContinuing } from './completion.ts'; pathsContinuing('lib/re', process.cwd()); // ['lib/repl/'] — a directory, and it says so pathsContinuing('nowhere/at/all', process.cwd()); // [] — an unreadable directory offers nothing