diff options
author | Mo <modisemorebodi@gmail.com> | 2020-11-21 20:23:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-21 19:23:24 +0100 |
commit | ce890f2ae7e8b557211e8f529180d30dc44ea7b5 (patch) | |
tree | c3a49d28c917f1adb0c802c94fa165928474ff84 /std/path/posix.ts | |
parent | 27dd78601669a92d0200ad197adcf0919fdc9e46 (diff) |
docs(std/path): add missing JSDoc (#8282)
Diffstat (limited to 'std/path/posix.ts')
-rw-r--r-- | std/path/posix.ts | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/std/path/posix.ts b/std/path/posix.ts index e5cbbd6c1..eb88be079 100644 --- a/std/path/posix.ts +++ b/std/path/posix.ts @@ -16,7 +16,10 @@ export const sep = "/"; export const delimiter = ":"; // path.resolve([from ...], to) -/** resolves `pathSegments` into an absolute path. */ +/** + * Resolves `pathSegments` into an absolute path. + * @param pathSegments an array of path segments + */ export function resolve(...pathSegments: string[]): string { let resolvedPath = ""; let resolvedAbsolute = false; @@ -61,7 +64,10 @@ export function resolve(...pathSegments: string[]): string { else return "."; } -/** Notmalize the `path`, resolving `'..'` and `'.'` segments. */ +/** + * Normalize the `path`, resolving `'..'` and `'.'` segments. + * @param path to be normalized + */ export function normalize(path: string): string { assertPath(path); @@ -81,12 +87,19 @@ export function normalize(path: string): string { return path; } +/** + * Verifies whether provided path is absolute + * @param path to be verified as absolute + */ export function isAbsolute(path: string): boolean { assertPath(path); return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH; } -/** Join all given a sequence of `paths`,then normalizes the resulting path. */ +/** + * Join all given a sequence of `paths`,then normalizes the resulting path. + * @param paths to be joined and normalized + */ export function join(...paths: string[]): string { if (paths.length === 0) return "."; let joined: string | undefined; @@ -102,7 +115,11 @@ export function join(...paths: string[]): string { return normalize(joined); } -/** Return the relative path from `from` to `to` based on current working directory. */ +/** + * Return the relative path from `from` to `to` based on current working directory. + * @param from path in current working directory + * @param to path in current working directory + */ export function relative(from: string, to: string): string { assertPath(from); assertPath(to); @@ -185,12 +202,19 @@ export function relative(from: string, to: string): string { } } +/** + * Resolves path to a namespace path + * @param path to resolve to namespace + */ export function toNamespacedPath(path: string): string { // Non-op on posix systems return path; } -/** Return the directory name of a `path`. */ +/** + * Return the directory name of a `path`. + * @param path to determine name for + */ export function dirname(path: string): string { assertPath(path); if (path.length === 0) return "."; @@ -214,7 +238,11 @@ export function dirname(path: string): string { return path.slice(0, end); } -/** Return the last portion of a `path`. Trailing directory separators are ignored. */ +/** + * Return the last portion of a `path`. Trailing directory separators are ignored. + * @param path to process + * @param ext of path directory + */ export function basename(path: string, ext = ""): string { if (ext !== undefined && typeof ext !== "string") { throw new TypeError('"ext" argument must be a string'); @@ -289,7 +317,10 @@ export function basename(path: string, ext = ""): string { } } -/** Return the extention of the `path`. */ +/** + * Return the extension of the `path`. + * @param path with extension + */ export function extname(path: string): string { assertPath(path); let startDot = -1; @@ -340,7 +371,10 @@ export function extname(path: string): string { return path.slice(startDot, end); } -/** Generate a path from `FormatInputPathObject` object. */ +/** + * Generate a path from `FormatInputPathObject` object. + * @param pathObject with path + */ export function format(pathObject: FormatInputPathObject): string { if (pathObject === null || typeof pathObject !== "object") { throw new TypeError( @@ -350,7 +384,10 @@ export function format(pathObject: FormatInputPathObject): string { return _format("/", pathObject); } -/** Return a `ParsedPath` object of the `path`. */ +/** + * Return a `ParsedPath` object of the `path`. + * @param path to process + */ export function parse(path: string): ParsedPath { assertPath(path); @@ -435,9 +472,11 @@ export function parse(path: string): ParsedPath { return ret; } -/** Converts a file URL to a path string. +/** + * Converts a file URL to a path string. * * fromFileUrl("file:///home/foo"); // "/home/foo" + * @param url of a file URL */ export function fromFileUrl(url: string | URL): string { url = url instanceof URL ? url : new URL(url); @@ -449,9 +488,11 @@ export function fromFileUrl(url: string | URL): string { ); } -/** Converts a path string to a file URL. +/** + * Converts a path string to a file URL. * * toFileUrl("/home/foo"); // new URL("file:///home/foo") + * @param path to convert to file URL */ export function toFileUrl(path: string): URL { if (!isAbsolute(path)) { |