Skip to content
0

katanakit-js / useReadDir

Function: useReadDir() ​

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

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

Lists a directory with type flags resolved per entry.

Parameters ​

ParameterTypeDescription
pathstringDirectory path.
options?{ recursive?: boolean; }recursive: true walks nested directories.
options.recursive?boolean-

Returns ​

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

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

Example ​

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

Released under the MIT License.