Skip to content

UseGetBasename

katanakit-js / useGetBasename

function useGetBasename(filePath, suffix?): Promise<string>;

Defined in: infrastructure/filesystem/path.service.ts:133

Returns the last portion of a path (file name).

Parameter Type Description
filePath string The path to inspect.
suffix? string Optional suffix to strip (e.g. ".json").

Promise<string>

The base name.

await useGetBasename("/data/books.json"); // "books.json"
await useGetBasename("/data/books.json", ".json"); // "books"