UNPKG

@stryke/path

Version:

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

32 lines 1.27 kB
//#region src/join-paths.d.ts /** * Joins all given path segments together using the platform-specific separator as a delimiter. * * @remarks * Multiple segments can be provided as separate arguments. The resulting path is normalized to remove any redundant or unnecessary segments. * * @example * ```ts * import { joinPaths } from 'stryke/path'; * * const fullPath = joinPaths('folder1', 'folder2', '..', 'folder3', 'file.txt'); * console.log(fullPath); // Output: 'folder1/folder3/file.txt' * * const absolutePath = joinPaths('/root', 'folder', '.', 'subfolder', 'file.txt'); * console.log(absolutePath); // Output: '/root/folder/subfolder/file.txt' * * const windowsPath = joinPaths('C:\\', 'Users', 'Public', '..', 'Documents', 'file.txt'); * console.log(windowsPath); // Output: 'C:/Users/Documents/file.txt' * * const uncPath = joinPaths('\\\\Server\\Share', 'Folder', 'File.txt'); * console.log(uncPath); // Output: '//Server/Share/Folder/File.txt' * ``` * * @param segments - The path segments to join. * @returns The joined and normalized path string. */ declare function joinPaths(...segments: string[]): string; declare const join: typeof joinPaths; //#endregion export { join, joinPaths }; //# sourceMappingURL=join-paths.d.mts.map