Skip to content

UseReadDir

katanakit-js / useReadDir

function useReadDir(path, options?): Promise<FilesystemResult<{
isDirectory: boolean;
isFile: boolean;
name: string;
path: string;
}[]>>;

Defined in: infrastructure/filesystem/filesystem.service.ts:327

Lists a directory with type flags resolved per entry.

Parameter Type Description
path string Directory path.
options? { recursive?: boolean; } recursive: true walks nested directories.
options.recursive? boolean -

Promise<FilesystemResult<{ isDirectory: boolean; isFile: boolean; name: string; path: string; }[]>>

Safe Result with { name, path, isFile, isDirectory } entries.

const result = await useReadDir("content", { recursive: true });
if (result.ok) result.data.filter((entry) => entry.isFile);