UNPKG

keep-a-changelog

Version:

Node package to parse and generate changelogs following the [keepachangelog](https://keepachangelog.com/) format.

40 lines (39 loc) 1.29 kB
"use strict"; // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. Object.defineProperty(exports, "__esModule", { value: true }); exports.basename = basename; const _os_js_1 = require("./_os.js"); const basename_js_1 = require("./posix/basename.js"); const basename_js_2 = require("./windows/basename.js"); /** * Return the last portion of a path. * * The trailing directory separators are ignored, and optional suffix is * removed. * * @example Usage * ```ts * import { basename } from "@std/path/basename"; * import { assertEquals } from "@std/assert"; * * if (Deno.build.os === "windows") { * assertEquals(basename("C:\\user\\Documents\\image.png"), "image.png"); * } else { * assertEquals(basename("/home/user/Documents/image.png"), "image.png"); * } * ``` * * Note: If you are working with file URLs, * use the new version of `basename` from `@std/path/unstable-basename`. * * @param path Path to extract the name from. * @param suffix Suffix to remove from extracted name. * * @returns The basename of the path. */ function basename(path, suffix = "") { return _os_js_1.isWindows ? (0, basename_js_2.basename)(path, suffix) : (0, basename_js_1.basename)(path, suffix); }