UseGetBasename
katanakit-js / useGetBasename
Function: useGetBasename()
Section titled “Function: useGetBasename()”function useGetBasename(filePath, suffix?): Promise<string>;Defined in: infrastructure/filesystem/path.service.ts:133
Returns the last portion of a path (file name).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
filePath |
string |
The path to inspect. |
suffix? |
string |
Optional suffix to strip (e.g. ".json"). |
Returns
Section titled “Returns”Promise<string>
The base name.
Example
Section titled “Example”await useGetBasename("/data/books.json"); // "books.json"await useGetBasename("/data/books.json", ".json"); // "books"