UNPKG

@stryke/path

Version:

A package containing various utilities that expand the functionality of NodeJs's built-in `path` module

19 lines (17 loc) 577 B
import { joinPaths } from "./join-paths.mjs"; //#region src/resolve-parent-path.ts /** * Resolve the parent path of the provided path. * * @param path - The path to resolve. * @param count - The number of parent directories to traverse. * @returns The parent path of the provided path. */ const resolveParentPath = (path, count = 1) => { let parentPath = path.replaceAll(/\/+$/g, ""); for (let i = 0; i < count; i++) parentPath = joinPaths(parentPath, ".."); return parentPath; }; //#endregion export { resolveParentPath }; //# sourceMappingURL=resolve-parent-path.mjs.map