@kikiutils/shared 18.0.0 → 18.1.0

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.
Files changed (156) hide show
  1. package/dist/buffer.d.ts +19 -21
  2. package/dist/buffer.d.ts.map +1 -1
  3. package/dist/buffer.js +18 -19
  4. package/dist/buffer.js.map +1 -1
  5. package/dist/classes/enhanced-date.d.ts +425 -0
  6. package/dist/classes/enhanced-date.d.ts.map +1 -0
  7. package/dist/classes/enhanced-date.js +591 -0
  8. package/dist/classes/enhanced-date.js.map +1 -0
  9. package/dist/classes/path.d.ts +211 -48
  10. package/dist/classes/path.d.ts.map +1 -1
  11. package/dist/classes/path.js +181 -52
  12. package/dist/classes/path.js.map +1 -1
  13. package/dist/classes/precision-number.d.ts +44 -39
  14. package/dist/classes/precision-number.d.ts.map +1 -1
  15. package/dist/classes/precision-number.js +51 -45
  16. package/dist/classes/precision-number.js.map +1 -1
  17. package/dist/classes/ssh-client.d.ts +3 -4
  18. package/dist/classes/ssh-client.d.ts.map +1 -1
  19. package/dist/classes/ssh-client.js +2 -2
  20. package/dist/classes/ssh-client.js.map +1 -1
  21. package/dist/clipboard.d.ts +25 -26
  22. package/dist/clipboard.d.ts.map +1 -1
  23. package/dist/clipboard.js +23 -23
  24. package/dist/clipboard.js.map +1 -1
  25. package/dist/consola.d.ts +12 -15
  26. package/dist/consola.d.ts.map +1 -1
  27. package/dist/consola.js +10 -12
  28. package/dist/consola.js.map +1 -1
  29. package/dist/crypto-hash.d.ts +65 -56
  30. package/dist/crypto-hash.d.ts.map +1 -1
  31. package/dist/crypto-hash.js +55 -45
  32. package/dist/crypto-hash.js.map +1 -1
  33. package/dist/datetime.d.ts +41 -53
  34. package/dist/datetime.d.ts.map +1 -1
  35. package/dist/datetime.js +53 -66
  36. package/dist/datetime.js.map +1 -1
  37. package/dist/element-plus.d.ts +13 -14
  38. package/dist/element-plus.d.ts.map +1 -1
  39. package/dist/element-plus.js +11 -11
  40. package/dist/element-plus.js.map +1 -1
  41. package/dist/enum.d.ts +39 -36
  42. package/dist/enum.d.ts.map +1 -1
  43. package/dist/enum.js +36 -32
  44. package/dist/enum.js.map +1 -1
  45. package/dist/env.d.ts +22 -15
  46. package/dist/env.d.ts.map +1 -1
  47. package/dist/env.js +20 -12
  48. package/dist/env.js.map +1 -1
  49. package/dist/event-awaiter.d.ts +47 -52
  50. package/dist/event-awaiter.d.ts.map +1 -1
  51. package/dist/event-awaiter.js +46 -50
  52. package/dist/event-awaiter.js.map +1 -1
  53. package/dist/general.d.ts +22 -17
  54. package/dist/general.d.ts.map +1 -1
  55. package/dist/general.js.map +1 -1
  56. package/dist/hash.d.ts +24 -21
  57. package/dist/hash.d.ts.map +1 -1
  58. package/dist/hash.js +20 -16
  59. package/dist/hash.js.map +1 -1
  60. package/dist/math.d.ts +20 -19
  61. package/dist/math.d.ts.map +1 -1
  62. package/dist/math.js +14 -12
  63. package/dist/math.js.map +1 -1
  64. package/dist/number.d.ts +10 -9
  65. package/dist/number.d.ts.map +1 -1
  66. package/dist/number.js +9 -7
  67. package/dist/number.js.map +1 -1
  68. package/dist/object.d.ts +22 -10
  69. package/dist/object.d.ts.map +1 -1
  70. package/dist/object.js +21 -8
  71. package/dist/object.js.map +1 -1
  72. package/dist/pino.d.ts +12 -15
  73. package/dist/pino.d.ts.map +1 -1
  74. package/dist/pino.js +10 -15
  75. package/dist/pino.js.map +1 -1
  76. package/dist/random.d.ts +17 -15
  77. package/dist/random.d.ts.map +1 -1
  78. package/dist/random.js +16 -13
  79. package/dist/random.js.map +1 -1
  80. package/dist/redis/script-runner.d.ts +57 -0
  81. package/dist/redis/script-runner.d.ts.map +1 -0
  82. package/dist/redis/script-runner.js +46 -0
  83. package/dist/redis/script-runner.js.map +1 -0
  84. package/dist/storages/lru/keyed-store.d.ts +18 -14
  85. package/dist/storages/lru/keyed-store.d.ts.map +1 -1
  86. package/dist/storages/lru/keyed-store.js +17 -12
  87. package/dist/storages/lru/keyed-store.js.map +1 -1
  88. package/dist/storages/redis/keyed-store.d.ts +11 -21
  89. package/dist/storages/redis/keyed-store.d.ts.map +1 -1
  90. package/dist/storages/redis/keyed-store.js +10 -19
  91. package/dist/storages/redis/keyed-store.js.map +1 -1
  92. package/dist/storages/redis/msgpack.d.ts +33 -13
  93. package/dist/storages/redis/msgpack.d.ts.map +1 -1
  94. package/dist/storages/redis/msgpack.js +32 -11
  95. package/dist/storages/redis/msgpack.js.map +1 -1
  96. package/dist/storages/redis/types.d.ts +34 -17
  97. package/dist/storages/redis/types.d.ts.map +1 -1
  98. package/dist/string.d.ts +12 -11
  99. package/dist/string.d.ts.map +1 -1
  100. package/dist/string.js +20 -15
  101. package/dist/string.js.map +1 -1
  102. package/dist/time.d.ts +35 -10
  103. package/dist/time.d.ts.map +1 -1
  104. package/dist/time.js +49 -9
  105. package/dist/time.js.map +1 -1
  106. package/dist/types/filtered-key-path.d.ts +4 -15
  107. package/dist/types/filtered-key-path.d.ts.map +1 -1
  108. package/dist/types/index.d.ts +10 -10
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/vue.d.ts +7 -7
  111. package/dist/types/vue.d.ts.map +1 -1
  112. package/dist/url.d.ts +15 -14
  113. package/dist/url.d.ts.map +1 -1
  114. package/dist/url.js +12 -10
  115. package/dist/url.js.map +1 -1
  116. package/dist/vue.d.ts +19 -21
  117. package/dist/vue.d.ts.map +1 -1
  118. package/dist/vue.js +15 -16
  119. package/dist/vue.js.map +1 -1
  120. package/dist/web.d.ts +14 -11
  121. package/dist/web.d.ts.map +1 -1
  122. package/dist/web.js +12 -8
  123. package/dist/web.js.map +1 -1
  124. package/package.json +20 -20
  125. package/src/buffer.ts +18 -19
  126. package/src/classes/enhanced-date.ts +665 -0
  127. package/src/classes/path.ts +232 -91
  128. package/src/classes/precision-number.ts +61 -53
  129. package/src/classes/ssh-client.ts +8 -5
  130. package/src/clipboard.ts +23 -23
  131. package/src/consola.ts +10 -12
  132. package/src/crypto-hash.ts +55 -45
  133. package/src/datetime.ts +65 -85
  134. package/src/element-plus.ts +11 -11
  135. package/src/enum.ts +36 -32
  136. package/src/env.ts +20 -12
  137. package/src/event-awaiter.ts +49 -50
  138. package/src/general.ts +20 -14
  139. package/src/hash.ts +20 -16
  140. package/src/math.ts +18 -16
  141. package/src/number.ts +9 -7
  142. package/src/object.ts +21 -8
  143. package/src/pino.ts +11 -15
  144. package/src/random.ts +16 -13
  145. package/src/redis/script-runner.ts +107 -0
  146. package/src/storages/lru/keyed-store.ts +17 -12
  147. package/src/storages/redis/keyed-store.ts +10 -19
  148. package/src/storages/redis/msgpack.ts +32 -11
  149. package/src/storages/redis/types.ts +32 -14
  150. package/src/string.ts +10 -8
  151. package/src/time.ts +52 -8
  152. package/src/types/filtered-key-path.ts +9 -14
  153. package/src/types/vue.ts +6 -5
  154. package/src/url.ts +12 -10
  155. package/src/vue.ts +15 -16
  156. package/src/web.ts +12 -8
@@ -2,20 +2,7 @@ import type { Buffer } from 'node:buffer';
2
2
  import type { Abortable } from 'node:events';
3
3
  import type * as fs from 'node:fs';
4
4
  import * as fsp from 'node:fs/promises';
5
- import {
6
- basename,
7
- dirname,
8
- extname,
9
- format,
10
- isAbsolute,
11
- join,
12
- normalize,
13
- parse,
14
- relative,
15
- resolve,
16
- toNamespacedPath,
17
- } from 'node:path';
18
- import type * as nodePath from 'node:path';
5
+ import * as nodePath from 'node:path';
19
6
 
20
7
  type DropFirstParameters<T extends (...args: any) => any> = Parameters<T> extends [any, ...infer R] ? R : never;
21
8
 
@@ -25,34 +12,30 @@ type DropFirstParameters<T extends (...args: any) => any> = Parameters<T> extend
25
12
  export type PathLike = fs.PathLike | Path;
26
13
 
27
14
  /**
28
- * Class representing a file system path with various utility methods for path operations.
15
+ * An immutable file system path with Node.js path and file operations.
29
16
  *
30
- * All methods in the `Path` class are immutable, returning new instances with modified values
31
- * and leaving the original instance unchanged.
17
+ * @remarks
18
+ * Path-composition methods return new instances and leave this instance unchanged.
19
+ * File operations act on the stored path and forward Node.js defaults and promise rejections.
20
+ * They do not update the stored path, including after a successful rename.
21
+ * The constructor joins stringified inputs using the platform-specific Node.js path rules.
32
22
  */
33
23
  export class Path {
24
+ // Private instance properties
34
25
  readonly #value: string;
35
26
 
27
+ // Constructor
28
+
36
29
  /**
37
30
  * Creates a normalized path value by joining the provided path segments.
38
31
  *
39
- * @param {PathLike[]} paths - Path segments accepted by Node.js `path.join` or another `Path` instance
32
+ * @param paths - Path segments accepted by Node.js `path.join` or another `Path` instance.
40
33
  */
41
34
  constructor(...paths: PathLike[]) {
42
- this.#value = join(...this.#toStrings(paths));
43
- }
44
-
45
- // Symbols
46
- [Symbol.for('nodejs.util.inspect.custom')]() {
47
- return this.#value;
48
- }
49
-
50
- [Symbol.toPrimitive](hint: string) {
51
- if (hint === 'number') throw new TypeError('Cannot convert a Path to a number');
52
- return this.#value;
35
+ this.#value = nodePath.join(...this.#toStrings(paths));
53
36
  }
54
37
 
55
- // Private methods
38
+ // Private instance methods
56
39
  #newInstance(...paths: PathLike[]) {
57
40
  return new Path(...paths);
58
41
  }
@@ -61,17 +44,19 @@ export class Path {
61
44
  return paths.map((path) => path.toString());
62
45
  }
63
46
 
64
- // Public getters
47
+ // Public instance accessors
65
48
 
66
49
  /**
67
- * @see {@link nodePath.dirname}
50
+ * The parent directory as a new `Path`; this instance is unchanged.
51
+ *
52
+ * @see {@link Path.dirname}
68
53
  */
69
54
  get parent() {
70
55
  return this.dirname();
71
56
  }
72
57
 
73
58
  /**
74
- * Returns the internal path string value.
59
+ * The normalized path string stored by this instance.
75
60
  */
76
61
  get value() {
77
62
  return this.#value;
@@ -80,82 +65,149 @@ export class Path {
80
65
  // Public static methods
81
66
 
82
67
  /**
83
- * @see {@link nodePath.format}
68
+ * Creates a new path from a Node.js path object.
69
+ *
70
+ * @param pathObject - The path components to format.
71
+ *
72
+ * @returns A new normalized `Path`.
73
+ *
74
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.format}
84
75
  */
85
76
  static format(pathObject: nodePath.FormatInputPathObject) {
86
- return new Path(format(pathObject));
77
+ return new Path(nodePath.format(pathObject));
87
78
  }
88
79
 
89
80
  /**
90
- * @see {@link nodePath.resolve}
81
+ * Resolves joined path segments to an absolute path.
82
+ *
83
+ * @remarks
84
+ * Inputs are joined before resolution; unlike Node.js `path.resolve`,
85
+ * later absolute segments do not reset the path.
86
+ *
87
+ * @param paths - The stringified path segments to join.
88
+ *
89
+ * @returns A new absolute `Path`.
90
+ *
91
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.resolve}
91
92
  */
92
93
  static resolve(...paths: PathLike[]) {
93
94
  return new this(...paths).resolve();
94
95
  }
95
96
 
96
- // Public base methods
97
+ // Public instance methods
98
+ [Symbol.for('nodejs.util.inspect.custom')]() {
99
+ return this.#value;
100
+ }
101
+
102
+ [Symbol.toPrimitive](hint: string) {
103
+ if (hint === 'number') throw new TypeError('Cannot convert a Path to a number');
104
+ return this.#value;
105
+ }
97
106
 
98
107
  /**
99
- * @see {@link nodePath.basename}
108
+ * Returns the final component of this path.
109
+ *
110
+ * @param suffix - An optional exact suffix to remove.
111
+ *
112
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.basename}
100
113
  */
101
114
  basename(suffix?: string) {
102
- return basename(this.#value, suffix);
115
+ return nodePath.basename(this.#value, suffix);
103
116
  }
104
117
 
105
118
  /**
106
- * @see {@link nodePath.dirname}
119
+ * Returns the parent directory of this path.
120
+ *
121
+ * @returns A new `Path`; this instance is unchanged.
122
+ *
123
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.dirname}
107
124
  */
108
125
  dirname() {
109
- return this.#newInstance(dirname(this.#value));
126
+ return this.#newInstance(nodePath.dirname(this.#value));
110
127
  }
111
128
 
112
129
  /**
113
- * @see {@link nodePath.extname}
130
+ * Returns the extension of the final path component.
131
+ *
132
+ * @returns The extension including its leading dot, or an empty string when absent.
133
+ *
134
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.extname}
114
135
  */
115
136
  extname() {
116
- return extname(this.#value);
137
+ return nodePath.extname(this.#value);
117
138
  }
118
139
 
119
140
  /**
120
- * @see {@link nodePath.isAbsolute}
141
+ * Checks whether this path is absolute on the current platform.
142
+ *
143
+ * @returns Whether this path is absolute.
144
+ *
145
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.isAbsolute}
121
146
  */
122
147
  isAbsolute() {
123
- return isAbsolute(this.#value);
148
+ return nodePath.isAbsolute(this.#value);
124
149
  }
125
150
 
126
151
  /**
127
- * @see {@link nodePath.normalize}
152
+ * Normalizes separators and relative segments in this path.
153
+ *
154
+ * @returns A new `Path`; this instance is unchanged.
155
+ *
156
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.normalize}
128
157
  */
129
158
  normalize() {
130
- return this.#newInstance(normalize(this.#value));
159
+ return this.#newInstance(nodePath.normalize(this.#value));
131
160
  }
132
161
 
133
162
  /**
134
- * @see {@link nodePath.join}
163
+ * Joins additional segments onto this path.
164
+ *
165
+ * @param paths - The stringified path segments to append.
166
+ *
167
+ * @returns A new normalized `Path`; this instance is unchanged.
168
+ *
169
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.join}
135
170
  */
136
171
  join(...paths: PathLike[]) {
137
172
  return this.#newInstance(this.#value, ...this.#toStrings(paths));
138
173
  }
139
174
 
140
175
  /**
141
- * @see {@link nodePath.parse}
176
+ * Parses this path into its root, directory, basename, extension, and name.
177
+ *
178
+ * @returns A new object containing the path components.
179
+ *
180
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.parse}
142
181
  */
143
182
  parse() {
144
- return parse(this.#value);
183
+ return nodePath.parse(this.#value);
145
184
  }
146
185
 
147
186
  /**
148
- * @see {@link nodePath.relative}
187
+ * Computes a relative path from this path to the destination.
188
+ *
189
+ * @param to - The destination path.
190
+ *
191
+ * @returns A new `Path`; this instance is unchanged.
192
+ *
193
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.relative}
149
194
  */
150
195
  relative(to: PathLike) {
151
- return this.#newInstance(relative(this.#value, to.toString()));
196
+ return this.#newInstance(nodePath.relative(this.#value, to.toString()));
152
197
  }
153
198
 
154
199
  /**
155
- * @see {@link nodePath.resolve}
200
+ * Resolves this path to an absolute path using the current working directory.
201
+ *
202
+ * @remarks
203
+ * Relative paths use the current working directory. This instance is unchanged.
204
+ *
205
+ * @returns A new absolute `Path`.
206
+ *
207
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.resolve}
156
208
  */
157
209
  resolve() {
158
- return this.#newInstance(resolve(this.#value));
210
+ return this.#newInstance(nodePath.resolve(this.#value));
159
211
  }
160
212
 
161
213
  toJSON() {
@@ -163,71 +215,97 @@ export class Path {
163
215
  }
164
216
 
165
217
  /**
166
- * @see {@link nodePath.toNamespacedPath}
218
+ * Converts this path to the Windows namespace form when applicable.
219
+ *
220
+ * @returns The namespace-converted path string; this instance is unchanged.
221
+ * On non-Windows platforms, the path text is unchanged.
222
+ *
223
+ * @see {@link https://nodejs.org/api/path.html | Node.js path.toNamespacedPath}
167
224
  */
168
225
  toNamespacedPath() {
169
- return toNamespacedPath(this.#value);
226
+ return nodePath.toNamespacedPath(this.#value);
170
227
  }
171
228
 
172
229
  /**
173
- * Converts the Path instance to a string.
174
- * This method returns the internal path string value,
175
- * making it useful for implicit and explicit string conversions.
230
+ * Returns the stored path as a string.
176
231
  */
177
232
  toString() {
178
233
  return this.#value;
179
234
  }
180
235
 
181
- // Some commonly used promise fs methods
182
-
183
236
  /**
184
- * @see {@link fsp.access}
237
+ * Checks access permissions for the stored path.
238
+ *
239
+ * @remarks
240
+ * The promise resolves when the access check succeeds and rejects if access is denied or the path is missing.
241
+ *
242
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.access}
185
243
  */
186
244
  access(...args: DropFirstParameters<typeof fsp.access>) {
187
245
  return fsp.access(this.#value, ...args);
188
246
  }
189
247
 
190
248
  /**
191
- * @see {@link fsp.appendFile}
249
+ * Appends data to the file at the stored path.
250
+ *
251
+ * @remarks
252
+ * The promise resolves when appending completes; a missing file is created according to the supplied options.
253
+ *
254
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.appendFile}
192
255
  */
193
256
  appendFile(...args: DropFirstParameters<typeof fsp.appendFile>) {
194
257
  return fsp.appendFile(this.#value, ...args);
195
258
  }
196
259
 
197
260
  /**
198
- * @see {@link fsp.chmod}
261
+ * Changes the permissions of the stored path.
262
+ *
263
+ * @remarks
264
+ * The promise resolves when the permissions are changed.
265
+ *
266
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.chmod}
199
267
  */
200
268
  chmod(...args: DropFirstParameters<typeof fsp.chmod>) {
201
269
  return fsp.chmod(this.#value, ...args);
202
270
  }
203
271
 
204
272
  /**
205
- * @see {@link fsp.chown}
273
+ * Changes the owner and group of the stored path.
274
+ *
275
+ * @remarks
276
+ * The promise resolves when the ownership is changed.
277
+ *
278
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.chown}
206
279
  */
207
280
  chown(...args: DropFirstParameters<typeof fsp.chown>) {
208
281
  return fsp.chown(this.#value, ...args);
209
282
  }
210
283
 
211
284
  /**
212
- * @see {@link fsp.copyFile}
285
+ * Copies the file at the stored path to a destination.
286
+ *
287
+ * @remarks
288
+ * The promise resolves when copying completes. The stored path remains the source path.
289
+ *
290
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.copyFile}
213
291
  */
214
292
  copyFile(...args: DropFirstParameters<typeof fsp.copyFile>) {
215
293
  return fsp.copyFile(this.#value, ...args);
216
294
  }
217
295
 
218
296
  /**
219
- * @see {@link fsp.mkdir}
297
+ * Creates a directory at the stored path.
298
+ *
299
+ * @remarks
300
+ * The promise resolves after creation. Recursive mode resolves to the first created directory path, or
301
+ * `undefined` if no directory is created; nonrecursive mode resolves without a value.
302
+ *
303
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.mkdir}
220
304
  */
221
- mkdir(
222
- options: fs.MakeDirectoryOptions & {
223
- recursive: true;
224
- },
225
- ): Promise<string>;
305
+ mkdir(options: fs.MakeDirectoryOptions & { recursive: true }): Promise<string | undefined>;
226
306
  mkdir(
227
307
  options?:
228
- | (fs.MakeDirectoryOptions & {
229
- recursive?: false;
230
- })
308
+ | (fs.MakeDirectoryOptions & { recursive?: false })
231
309
  | fs.Mode
232
310
  | null,
233
311
  ): Promise<void>;
@@ -237,17 +315,26 @@ export class Path {
237
315
  }
238
316
 
239
317
  /**
240
- * @see {@link fsp.open}
318
+ * Opens the file at the stored path.
319
+ *
320
+ * @remarks
321
+ * The promise resolves to a new file handle. The caller must close the handle when it is no longer needed.
322
+ *
323
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.open}
241
324
  */
242
325
  open(...args: DropFirstParameters<typeof fsp.open>) {
243
326
  return fsp.open(this.#value, ...args);
244
327
  }
245
328
 
246
329
  /**
247
- * @see {@link fsp.readdir}
330
+ * Reads the entries of the directory at the stored path.
331
+ *
332
+ * @remarks
333
+ * The promise resolves to names, buffers, or directory entries according to the options.
334
+ *
335
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.readdir}
248
336
  */
249
337
  readdir(
250
- path: PathLike,
251
338
  options?:
252
339
  | BufferEncoding
253
340
  | (fs.ObjectEncodingOptions & {
@@ -257,7 +344,6 @@ export class Path {
257
344
  | null,
258
345
  ): Promise<string[]>;
259
346
  readdir(
260
- path: PathLike,
261
347
  options:
262
348
  | 'buffer'
263
349
  | {
@@ -267,7 +353,6 @@ export class Path {
267
353
  },
268
354
  ): Promise<Buffer[]>;
269
355
  readdir(
270
- path: PathLike,
271
356
  options?:
272
357
  | BufferEncoding
273
358
  | (fs.ObjectEncodingOptions & {
@@ -277,14 +362,12 @@ export class Path {
277
362
  | null,
278
363
  ): Promise<Buffer[] | string[]>;
279
364
  readdir(
280
- path: PathLike,
281
365
  options: fs.ObjectEncodingOptions & {
282
366
  recursive?: boolean;
283
367
  withFileTypes: true;
284
368
  },
285
369
  ): Promise<fs.Dirent[]>;
286
370
  readdir(
287
- path: PathLike,
288
371
  options: {
289
372
  encoding: 'buffer';
290
373
  recursive?: boolean;
@@ -296,7 +379,12 @@ export class Path {
296
379
  }
297
380
 
298
381
  /**
299
- * @see {@link fsp.readFile}
382
+ * Reads the entire file at the stored path.
383
+ *
384
+ * @remarks
385
+ * The promise resolves to a string when a text encoding is supplied, or a `Buffer` otherwise.
386
+ *
387
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.readFile}
300
388
  */
301
389
  readFile(
302
390
  options?:
@@ -329,60 +417,113 @@ export class Path {
329
417
  }
330
418
 
331
419
  /**
332
- * @see {@link fsp.rename}
420
+ * Renames or moves the file or directory at the stored path.
421
+ *
422
+ * @remarks
423
+ * The promise resolves when the rename completes. This instance retains its original stored path.
424
+ *
425
+ * @param newPath - The destination path; this instance retains its original value.
426
+ *
427
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.rename}
333
428
  */
334
429
  rename(newPath: PathLike) {
335
430
  return fsp.rename(this.#value, newPath.toString());
336
431
  }
337
432
 
338
433
  /**
339
- * @see {@link fsp.rm}
434
+ * Removes the file or directory at the stored path.
435
+ *
436
+ * @remarks
437
+ * The promise resolves after removal according to the supplied options.
438
+ *
439
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.rm}
340
440
  */
341
441
  rm(...args: DropFirstParameters<typeof fsp.rm>) {
342
442
  return fsp.rm(this.#value, ...args);
343
443
  }
344
444
 
345
445
  /**
346
- * @see {@link fsp.rmdir}
446
+ * Removes the directory at the stored path.
447
+ *
448
+ * @remarks
449
+ * The promise resolves after directory removal.
450
+ *
451
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.rmdir}
347
452
  */
348
453
  rmdir(...args: DropFirstParameters<typeof fsp.rmdir>) {
349
454
  return fsp.rmdir(this.#value, ...args);
350
455
  }
351
456
 
352
457
  /**
353
- * @see {@link fsp.stat}
458
+ * Reads file system metadata for the stored path.
459
+ *
460
+ * @remarks
461
+ * The promise resolves to `Stats`, or `BigIntStats` when `bigint` is enabled.
462
+ * If `throwIfNoEntry` is `false`, a missing path resolves to `undefined` instead of rejecting.
463
+ *
464
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.stat}
354
465
  */
355
466
  stat(
356
467
  opts?: fs.StatOptions & {
357
468
  bigint?: false;
469
+ throwIfNoEntry?: true;
358
470
  },
359
471
  ): Promise<fs.Stats>;
360
472
  stat(
361
473
  opts: fs.StatOptions & {
362
474
  bigint: true;
475
+ throwIfNoEntry?: true;
363
476
  },
364
477
  ): Promise<fs.BigIntStats>;
365
- stat(opts?: fs.StatOptions): Promise<fs.BigIntStats | fs.Stats>;
478
+ stat(
479
+ opts: fs.StatOptions & {
480
+ bigint?: false;
481
+ throwIfNoEntry: false;
482
+ },
483
+ ): Promise<fs.Stats | undefined>;
484
+ stat(
485
+ opts: fs.StatOptions & {
486
+ bigint: true;
487
+ throwIfNoEntry: false;
488
+ },
489
+ ): Promise<fs.BigIntStats | undefined>;
490
+ stat(opts: fs.StatOptions & { throwIfNoEntry?: true }): Promise<fs.BigIntStats | fs.Stats>;
491
+ stat(opts?: fs.StatOptions): Promise<fs.BigIntStats | fs.Stats | undefined>;
366
492
  stat(...args: any): any {
367
493
  return fsp.stat(this.#value, ...args);
368
494
  }
369
495
 
370
496
  /**
371
- * @see {@link fsp.truncate}
497
+ * Truncates or extends the file at the stored path.
498
+ *
499
+ * @remarks
500
+ * The promise resolves when the file reaches the requested length in bytes; the default length is `0`.
501
+ *
502
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.truncate}
372
503
  */
373
504
  truncate(...args: DropFirstParameters<typeof fsp.truncate>) {
374
505
  return fsp.truncate(this.#value, ...args);
375
506
  }
376
507
 
377
508
  /**
378
- * @see {@link fsp.unlink}
509
+ * Deletes the file or symbolic link at the stored path.
510
+ *
511
+ * @remarks
512
+ * The promise resolves after deletion; directories are not removed.
513
+ *
514
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.unlink}
379
515
  */
380
516
  unlink() {
381
517
  return fsp.unlink(this.#value);
382
518
  }
383
519
 
384
520
  /**
385
- * @see {@link fsp.writeFile}
521
+ * Writes data to the file at the stored path.
522
+ *
523
+ * @remarks
524
+ * The promise resolves when writing completes; the default flag replaces existing file contents.
525
+ *
526
+ * @see {@link https://nodejs.org/api/fs.html | Node.js fsPromises.writeFile}
386
527
  */
387
528
  writeFile(...args: DropFirstParameters<typeof fsp.writeFile>) {
388
529
  return fsp.writeFile(this.#value, ...args);