@absolunet/ioc2.1.0

View on GitHub

PathHelper

Path helper.

Extends

Methods

basename(filePath, extensionopt)

Source:
See:
  • path#basename
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:
Name Type Attributes Description
filePath string The path to evaluate.
extension string <optional>
An extension to remove from the result.
Returns:
The basename of the given file path.
Type
string

dirname(filePath)

Source:
See:
  • path#dirname
Return the directory name of a path. Similar to the Unix dirname command.
Parameters:
Name Type Description
filePath string The path to evaluate.
Returns:
The directory name of the given file path.
Type
string

extname(filePath)

Source:
See:
  • path#extname
Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
Parameters:
Name Type Description
filePath string The path to evaluate.
Returns:
The extension name of the given file path.
Type
string

format(pathObject)

Source:
See:
  • path#format
Returns a path string from an object - the opposite of parse().
Parameters:
Name Type Description
pathObject FormatInputPathObject The path object to format.
Returns:
The formatted path.
Type
string

isAbsolute(filePath)

Source:
See:
  • path#isAbsolute
Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
Parameters:
Name Type Description
filePath string The path to test.
Returns:
Indicates that the path is an absolute path.
Type
boolean

isRelative(filePath)

Source:
See:
  • PathHelper#isAbsolute
Determines whether {path} is a relative path. An absolute path will always resolve to the same location, regardless of the working directory.
Parameters:
Name Type Description
filePath string The path to test.
Returns:
Indicates that the path is a relative path.
Type
boolean

join(…paths)

Source:
See:
  • path#join
Join all arguments together and normalize the resulting path. Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
Parameters:
Name Type Attributes Description
paths Array.<string> <repeatable>
The paths to join.
Returns:
The joined path.
Type
string

normalize(filePath)

Source:
See:
  • path#normalize
Normalize a string path, reducing '..' and '.' parts. When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
Parameters:
Name Type Description
filePath string The path to normalize.
Returns:
The normalized path.
Type
string

parse(filePath)

Source:
See:
  • path#parse
Returns an object from a path string - the opposite of format().
Parameters:
Name Type Description
filePath string The path to evaluate.
Returns:
The parsed path object.
Type
ParsedPath

relative(from, to)

Source:
See:
  • path#relative
Solve the relative path from {from} to {to}. At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
Parameters:
Name Type Description
from string The starting path.
to string The ending path.
Returns:
The relative path.
Type
string

resolve(…paths)

Source:
See:
  • path#resolve
The right-most parameter is considered {to}. Other parameters are considered an array of {from}. Starting from leftmost {from} parameter, resolves {to} to an absolute path. If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
Parameters:
Name Type Attributes Description
paths Array.<string> <repeatable>
The paths to join. Non-string arguments are ignored.
Returns:
The resolved path.
Type
string

slash(filePath)

Source:
Convert Windows delimiters to POSIX delimiters, removing backslashes in favor of slashes.
Parameters:
Name Type Description
filePath string The path to format.
Returns:
The formatted path.
Type
string

forwardCall(method, parametersopt)

Source:
Overrides:
Forward call to given object.
Parameters:
Name Type Attributes Default Description
method string The method to call.
parameters Array.<*> <optional>
[] The parameters to send to the forwarded instance method.
Returns:
The method result.
Type
*

getForward()

Source:
Overrides:
Get object which should receive the call forwarding.
Returns:
The forward instance.
Type
object