Skip to main content
default.PlatformPath.basename - node__path.d.ts - Node documentation
method default.PlatformPath.basename

Usage in Deno

```typescript import type mod from "node:node__path.d.ts"; ```
PlatformPath.basename(
path: string,
suffix?: string,
): string
Return the last portion of a path. Similar to the Unix basename command. Often used to extract the file name from a fully qualified path.

Parameters

path: string
the path to evaluate.
optional
suffix: string
optionally, an extension to remove from the result.

Return Type

string

Throws

TypeError
if `path` is not a string or if `ext` is given and is not a string.