@duplojs/utils 1.4.49 → 1.4.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,9 +78,7 @@ exports.Path = void 0;
78
78
  clearedPath = segment;
79
79
  continue;
80
80
  }
81
- const formattedSegment = segment
82
- .replace(Path.segmentTrailingRegex, "")
83
- .replace(Path.segmentRelativeRegex, "");
81
+ const formattedSegment = fix(segment);
84
82
  if (formattedSegment.startsWith("/")) {
85
83
  clearedPath = formattedSegment;
86
84
  continue;
@@ -111,4 +109,13 @@ exports.Path = void 0;
111
109
  return `${dotResult.join("/")}/${result.join("/")}`;
112
110
  }
113
111
  Path.resolveRelative = resolveRelative;
112
+ /**
113
+ * {@include common/path/fix/index.md}
114
+ */
115
+ function fix(path) {
116
+ return path
117
+ .replace(Path.segmentTrailingRegex, "")
118
+ .replace(Path.segmentRelativeRegex, "");
119
+ }
120
+ Path.fix = fix;
114
121
  })(exports.Path || (exports.Path = {}));
@@ -142,4 +142,25 @@ export declare namespace Path {
142
142
  *
143
143
  */
144
144
  function resolveRelative<GenericSegment extends string>(segments: AnyTuple<GenericSegment>): string;
145
+ /**
146
+ * Cleans a POSIX path by removing a trailing slash and a leading `./` prefix.
147
+ *
148
+ * **Supported call styles:**
149
+ * - Classic: `fix(path)` -> returns a cleaned path
150
+ *
151
+ * The function does not resolve `..` segments and only removes a single trailing slash and a single leading `./`.
152
+ *
153
+ * ```ts
154
+ * const trimmedTrailing = Path.fix("alpha/beta/");
155
+ * // trimmedTrailing: "alpha/beta"
156
+ * const trimmedRelative = Path.fix("./alpha/beta");
157
+ * // trimmedRelative: "alpha/beta"
158
+ * const cleanedBoth = Path.fix("./alpha/");
159
+ * // cleanedBoth: "alpha"
160
+ * ```
161
+ *
162
+ * @see https://utils.duplojs.dev/en/v1/api/common/path/fix
163
+ *
164
+ */
165
+ function fix(path: string): string;
145
166
  }
@@ -76,9 +76,7 @@ var Path;
76
76
  clearedPath = segment;
77
77
  continue;
78
78
  }
79
- const formattedSegment = segment
80
- .replace(Path.segmentTrailingRegex, "")
81
- .replace(Path.segmentRelativeRegex, "");
79
+ const formattedSegment = fix(segment);
82
80
  if (formattedSegment.startsWith("/")) {
83
81
  clearedPath = formattedSegment;
84
82
  continue;
@@ -109,6 +107,15 @@ var Path;
109
107
  return `${dotResult.join("/")}/${result.join("/")}`;
110
108
  }
111
109
  Path.resolveRelative = resolveRelative;
110
+ /**
111
+ * {@include common/path/fix/index.md}
112
+ */
113
+ function fix(path) {
114
+ return path
115
+ .replace(Path.segmentTrailingRegex, "")
116
+ .replace(Path.segmentRelativeRegex, "");
117
+ }
118
+ Path.fix = fix;
112
119
  })(Path || (Path = {}));
113
120
 
114
121
  export { Path };
@@ -5,7 +5,7 @@ export declare const failKind: import("../../common/kind").KindHandler<import(".
5
5
  * @deprecated use failKind
6
6
  */
7
7
  export declare const eitherFailKind: import("../../common/kind").KindHandler<import("../../common/kind").KindDefinition<"@DuplojsUtilsEither/fail", unknown>>;
8
- type _Fail = (Left<"fail", never> & Kind<typeof failKind.definition>);
8
+ type _Fail = (Left<"fail", void> & Kind<typeof failKind.definition>);
9
9
  export interface Fail extends _Fail {
10
10
  }
11
11
  /**
@@ -13,7 +13,7 @@ export interface Fail extends _Fail {
13
13
  */
14
14
  export type EitherFail = Fail;
15
15
  /**
16
- * Returns an Left<"fail", never>: perfect to signal a failure without carrying extra data.
16
+ * Returns an Left<"fail", void>: perfect to signal a failure without carrying extra data.
17
17
  *
18
18
  * Signature: `fail()` → returns a value
19
19
  *
@@ -5,7 +5,7 @@ export declare const okKind: import("../../common/kind").KindHandler<import("../
5
5
  * @deprecated use okKind
6
6
  */
7
7
  export declare const eitherOkKind: import("../../common/kind").KindHandler<import("../../common/kind").KindDefinition<"@DuplojsUtilsEither/ok", unknown>>;
8
- type _Ok = (Right<"ok", never> & Kind<typeof okKind.definition>);
8
+ type _Ok = (Right<"ok", void> & Kind<typeof okKind.definition>);
9
9
  export interface Ok extends _Ok {
10
10
  }
11
11
  /**
@@ -13,7 +13,7 @@ export interface Ok extends _Ok {
13
13
  */
14
14
  export type EitherOk = Ok;
15
15
  /**
16
- * Returns an Right<"ok", never>: an empty success that confirms an operation went fine without extra data.
16
+ * Returns an Right<"ok", void>: an empty success that confirms an operation went fine without extra data.
17
17
  *
18
18
  * Signature: `ok()` → returns a value
19
19
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duplojs/utils",
3
- "version": "1.4.49",
3
+ "version": "1.4.50",
4
4
  "author": {
5
5
  "name": "mathcovax",
6
6
  "url": "https://github.com/mathcovax"