Utility functions for working with file paths.
- Description:
Utility functions for working with file paths.
- Source:
Methods
(static) getDirname(metaUrl) → {string}
- Description:
Returns the directory name of the given file URL.
- Source:
Example
import { getDirname } from "nsuite";
const __dirname = getDirname(import.meta.url);
Parameters:
Name | Type | Description |
---|---|---|
metaUrl |
string | The file URL to extract the directory name from. |
Returns:
The directory name of the given file URL.
- Type
- string
(static) getFilePath(metaUrl) → {string}
- Description:
Converts a file URL to a file path.
- Source:
Example
import { getFilePath } from "nsuite";
const __filename = getFilePath(import.meta.url);
Parameters:
Name | Type | Description |
---|---|---|
metaUrl |
string | The file URL to convert. |
Returns:
The file path corresponding to the given file URL.
- Type
- string
(static) globMatchPaths(…pathArr) → {Promise.<Array.<string>>}
- Description:
Matches file paths using glob patterns.
- Source:
Example
import { globMatchPaths } from "nsuite";
const excelFileList = await globMatchPaths(
joinPath(__dirname, "materials/*.xlsx"),
);
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pathArr |
string |
<repeatable> |
The path segments to join and match using glob patterns. |
Returns:
A promise that resolves to an array of matched file paths.
- Type
- Promise.<Array.<string>>
(static) isPathExists(path) → {Promise.<boolean>}
- Description:
Checks if a given path exists.
- Source:
Example
import { isPathExists } from "nsuite";
const isExists = isPathExists("path/to/file.txt")
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The path to check. |
Returns:
A promise that resolves to true
if the path exists, otherwise false
.
- Type
- Promise.<boolean>
(static) joinPath(…args) → {string}
- Description:
Joins multiple path segments into a single path.
- Source:
Example
import { joinPath } from "nsuite";
const targetPath = joinPath("path", "to", "file.txt");
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
string |
<repeatable> |
The path segments to join. |
Returns:
The joined path.
- Type
- string
(static) joinPosixPath(…args) → {string}
- Description:
Joins multiple path segments into a single POSIX path.
- Source:
Example
import { joinPosixPath } from "nsuite";
const targetPath = joinPosixPath("path", "to", "file.txt");
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
string |
<repeatable> |
The path segments to join. |
Returns:
The joined POSIX path.
- Type
- string
(static) resolvePath(…args) → {string}
- Description:
Resolves multiple path segments to an absolute path.
- Source:
Example
import { resolvePath } from "nsuite";
const targetPath = resolvePath("path", "to", "file.txt");
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
string |
<repeatable> |
The path segments to resolve. |
Returns:
The resolved absolute path.
- Type
- string
(static) resolvePosixPath(…args) → {string}
- Description:
Resolves multiple path segments to an absolute POSIX path.
- Source:
Example
import { resolvePosixPath } from "nsuite";
const targetPath = resolvePosixPath("path", "to", "file.txt");
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
string |
<repeatable> |
The path segments to resolve. |
Returns:
The resolved absolute POSIX path.
- Type
- string