Skip to content

Commit fcb25d5

Browse files
committed
fix(58): refacto path function
1 parent 5a8773a commit fcb25d5

File tree

108 files changed

+823
-1443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+823
-1443
lines changed

docs/en/v1/api/common/index.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,10 @@ Defines named overrides (methods or default values) and applies them to an inter
178178
## Path
179179

180180
### [Path](/en/v1/api/common/path/)
181-
Mini-domain for path utilities (normalization, joining, extraction).
181+
Mini-domain for POSIX path utilities (resolution, extraction).
182182

183183
### [Path.isAbsolute](/en/v1/api/common/path/isAbsolute)
184-
Checks whether a path is absolute (POSIX, UNC, or Windows drive).
185-
186-
### [Path.isUnixPath](/en/v1/api/common/path/isUnixPath)
187-
Checks whether a path only uses Unix separators.
188-
189-
### [Path.normalize](/en/v1/api/common/path/normalize)
190-
Normalizes a path by resolving segments and separators.
191-
192-
### [Path.join](/en/v1/api/common/path/join)
193-
Joins path segments and normalizes the result.
184+
Checks whether a path is absolute.
194185

195186
### [Path.resolveFrom](/en/v1/api/common/path/resolveFrom)
196187
Resolves a list of segments from an origin.

docs/en/v1/api/common/path/getBaseName.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
outline: [2, 3]
3-
description: "The getBaseName() function returns the last segment of a path, with optional extension removal."
3+
description: "The getBaseName() function returns the last non-empty segment of a path, with optional extension removal."
44
prev:
55
text: "getParentFolderPath"
66
link: "/en/v1/api/common/path/getParentFolderPath"
@@ -11,7 +11,11 @@ next:
1111

1212
# getBaseName
1313

14-
The **`getBaseName()`** function returns the last segment of a path, with optional extension removal.
14+
The **`getBaseName()`** function returns the last non-empty segment of a path, with optional extension removal.
15+
16+
::: warning
17+
Works only with POSIX paths (not Windows paths).
18+
:::
1519

1620
## Interactive example
1721

@@ -32,6 +36,7 @@ function getBaseName<
3236
extension?: string;
3337
}
3438
): string;
39+
): string | null;
3540
```
3641

3742
## Parameters
@@ -41,7 +46,7 @@ function getBaseName<
4146

4247
## Return value
4348

44-
The last segment, with the extension removed when it matches.
49+
The last segment, with the extension removed when it matches, or `null` when no segment is available.
4550

4651
## See also
4752

docs/en/v1/api/common/path/getExtensionName.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
outline: [2, 3]
3-
description: "The getExtensionName() function returns the extension of a path, including the dot."
3+
description: "The getExtensionName() function returns the last extension of a path, including the dot."
44
prev:
55
text: "getBaseName"
66
link: "/en/v1/api/common/path/getBaseName"
@@ -11,7 +11,11 @@ next:
1111

1212
# getExtensionName
1313

14-
The **`getExtensionName()`** function returns the extension of a path, including the dot.
14+
The **`getExtensionName()`** function returns the last extension of a path, including the dot.
15+
16+
::: warning
17+
Works only with POSIX paths (not Windows paths).
18+
:::
1519

1620
## Interactive example
1721

@@ -28,7 +32,7 @@ function getExtensionName<
2832
GenericPath extends string
2933
>(
3034
path: GenericPath
31-
): string;
35+
): string | null;
3236
```
3337

3438
## Parameters
@@ -37,7 +41,7 @@ function getExtensionName<
3741

3842
## Return value
3943

40-
The extension including the dot (e.g. `.txt`) or an empty string when none is found.
44+
The extension including the dot (e.g. `.txt`) or `null` when none is found.
4145

4246
## See also
4347

docs/en/v1/api/common/path/getParentFolderPath.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
outline: [2, 3]
3-
description: "The getParentFolderPath() function returns the parent folder of a path."
3+
description: "The getParentFolderPath() function returns the parent folder of a POSIX path."
44
prev:
55
text: "resolveFrom"
66
link: "/en/v1/api/common/path/resolveFrom"
@@ -11,7 +11,11 @@ next:
1111

1212
# getParentFolderPath
1313

14-
The **`getParentFolderPath()`** function returns the parent folder of a path.
14+
The **`getParentFolderPath()`** function returns the parent folder of a POSIX path.
15+
16+
::: warning
17+
Works only with POSIX paths (not Windows paths).
18+
:::
1519

1620
## Interactive example
1721

docs/en/v1/api/common/path/index.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
outline: [2, 3]
3-
description: "Path utilities to normalize, join, and inspect cross-platform paths."
3+
description: "Path utilities to resolve and inspect POSIX paths."
44
prev:
55
text: "Common"
66
link: "/en/v1/api/common/"
@@ -11,7 +11,7 @@ next:
1111

1212
# Path
1313

14-
Path utilities to normalize, join, and inspect cross-platform paths.
14+
Path utilities to resolve and inspect POSIX paths.
1515

1616
## How to import?
1717

@@ -25,18 +25,12 @@ import * as Path from "@duplojs/utils/common/path";
2525
## Checks
2626

2727
### [isAbsolute](/en/v1/api/common/path/isAbsolute)
28-
Checks whether a path is absolute (POSIX, UNC, or Windows drive).
28+
Checks whether a path is absolute.
2929

30-
### [isUnixPath](/en/v1/api/common/path/isUnixPath)
31-
Checks whether a path only uses Unix separators.
30+
## Resolution
3231

33-
## Normalization and composition
34-
35-
### [normalize](/en/v1/api/common/path/normalize)
36-
Normalizes a path by resolving segments and separators.
37-
38-
### [join](/en/v1/api/common/path/join)
39-
Joins path segments and normalizes the result.
32+
### [resolveRelative](/en/v1/api/common/path/resolveRelative)
33+
Resolves multiple segments into a single path.
4034

4135
### [resolveFrom](/en/v1/api/common/path/resolveFrom)
4236
Resolves a list of segments from an origin.
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
---
22
outline: [2, 3]
3-
description: "The isAbsolute() function checks whether a path is absolute (POSIX, UNC, or Windows drive) and acts as a type guard."
3+
description: "The isAbsolute() function checks whether a POSIX path is absolute and does not traverse above root."
44
prev:
55
text: "Path"
66
link: "/en/v1/api/common/path/"
77
next:
8-
text: "isUnixPath"
9-
link: "/en/v1/api/common/path/isUnixPath"
8+
text: "resolveRelative"
9+
link: "/en/v1/api/common/path/resolveRelative"
1010
---
1111

1212
# isAbsolute
1313

14-
The **`isAbsolute()`** function checks whether a path is absolute (POSIX, UNC, or Windows drive) and acts as a type guard.
14+
The **`isAbsolute()`** function checks whether a path is absolute and does not traverse above root.
15+
16+
::: warning
17+
Works only with POSIX paths (not Windows paths).
18+
:::
1519

1620
## Interactive example
1721

1822
<MonacoTSEditor
1923
src="/examples/v1/api/common/path/isAbsolute/tryout.doc.ts"
2024
majorVersion="v1"
21-
height="313px"
25+
height="208px"
2226
/>
2327

2428
## Syntax
2529

2630
```typescript
27-
function isAbsolute<
28-
GenericPath extends string
29-
>(
30-
path: GenericPath
31-
): path is Extract<
32-
GenericPath,
33-
`/${string}` | `\\${string}` | `${string}:${"/" | "\\"}${string}`
34-
>;
31+
function isAbsolute(
32+
path: string
33+
): boolean;
3534
```
3635

3736
## Parameters
@@ -40,9 +39,8 @@ function isAbsolute<
4039

4140
## Return value
4241

43-
A boolean and a type guard that narrows the path when it is absolute.
42+
A boolean indicating whether the path is absolute.
4443

4544
## See also
4645

47-
- [`isUnixPath`](/en/v1/api/common/path/isUnixPath) - Checks for Unix separators
48-
- [`normalize`](/en/v1/api/common/path/normalize) - Normalizes a path
46+
- [`resolveFrom`](/en/v1/api/common/path/resolveFrom) - Resolves a list of segments from an origin

docs/en/v1/api/common/path/isUnixPath.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

docs/en/v1/api/common/path/join.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

docs/en/v1/api/common/path/normalize.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)