- Source:
Methods
(static) getUrlDirname(url) → {String}
- Description:
- Get the directory path for a file URL - Useful for __dirname from es module in node
 
 
- Source:
Example
const __dirname = getUrlDirname(import.meta.url);Parameters:
| Name | Type | Description | 
|---|---|---|
| url | String | The url string, ie 'import.meta.url' | 
Throws:
- 
        If url is not a string 
- Type
- TypeError
Returns:
The directory path
- Type
- String
(static) resolveFromUrlDir(url, relativePath) → {String}
- Description:
- Resolve a relative path from a file URL - useful for resolving paths relative to import.meta.url
 
 
- Source:
Example
const filePath = resolveFromUrlDir(import.meta.url, "my-file.txt");Parameters:
| Name | Type | Description | 
|---|---|---|
| url | String | The url string, ie 'import.meta.url' | 
| relativePath | String | The relative file path to resolve. | 
Throws:
- 
        If url or relativePath is not a string 
- Type
- TypeError
Returns:
The resolved absolute path
- Type
- String