@goodbyenjn/utils 26.4.0 → 26.4.2
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.
- package/README.md +78 -35
- package/dist/chunks/{chunk-486f65b0.js → chunk-11b9216b.js} +41 -40
- package/dist/chunks/chunk-1b381080.js +25 -0
- package/dist/chunks/{chunk-7ffde8d4.js → chunk-3ce2ea14.js} +14 -21
- package/dist/chunks/chunk-71e0c144.d.ts +168 -0
- package/dist/chunks/chunk-9fe6b612.d.ts +10 -0
- package/dist/chunks/{chunk-704a1835.d.ts → chunk-bd9f56dd.d.ts} +2 -1
- package/dist/common.d.ts +2 -187
- package/dist/common.js +2 -3
- package/dist/exec.d.ts +129 -0
- package/dist/exec.js +759 -0
- package/dist/fs.d.ts +422 -95
- package/dist/fs.js +859 -387
- package/dist/global-types.d.ts +70 -0
- package/dist/json.d.ts +29 -0
- package/dist/json.js +3 -0
- package/dist/remeda.d.ts +3 -1
- package/dist/remeda.js +2 -3
- package/dist/result.d.ts +2 -2
- package/dist/result.js +2 -3
- package/dist/types.js +1 -1
- package/package.json +22 -16
- package/dist/chunks/chunk-b61db0a7.js +0 -27
- package/dist/shell.d.ts +0 -101
- package/dist/shell.js +0 -781
package/dist/fs.d.ts
CHANGED
|
@@ -1,46 +1,22 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { A as Nil } from "./chunks/chunk-71e0c144.js";
|
|
3
|
+
import { i as Result, u as InferErrType } from "./chunks/chunk-bd9f56dd.js";
|
|
4
|
+
import { n as stringify, t as parse } from "./chunks/chunk-9fe6b612.js";
|
|
5
|
+
import * as nativeFs from "fs";
|
|
4
6
|
|
|
5
|
-
//#region node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.
|
|
7
|
+
//#region node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.4/node_modules/fdir/dist/index.d.mts
|
|
6
8
|
type FSLike = {
|
|
7
|
-
readdir: typeof nativeFs
|
|
8
|
-
readdirSync: typeof nativeFs
|
|
9
|
-
realpath: typeof nativeFs
|
|
10
|
-
realpathSync: typeof nativeFs
|
|
11
|
-
stat: typeof nativeFs
|
|
12
|
-
statSync: typeof nativeFs
|
|
9
|
+
readdir: typeof nativeFs.readdir;
|
|
10
|
+
readdirSync: typeof nativeFs.readdirSync;
|
|
11
|
+
realpath: typeof nativeFs.realpath;
|
|
12
|
+
realpathSync: typeof nativeFs.realpathSync;
|
|
13
|
+
stat: typeof nativeFs.stat;
|
|
14
|
+
statSync: typeof nativeFs.statSync;
|
|
13
15
|
};
|
|
14
16
|
//#endregion
|
|
15
|
-
//#region node_modules/.pnpm/tinyglobby@0.2.
|
|
16
|
-
//#region src/
|
|
17
|
-
|
|
18
|
-
* Converts a path to a pattern depending on the platform.
|
|
19
|
-
* Identical to {@link escapePath} on POSIX systems.
|
|
20
|
-
* @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
|
|
21
|
-
*/
|
|
22
|
-
declare const convertPathToPattern: (path: string) => string;
|
|
23
|
-
/**
|
|
24
|
-
* Escapes a path's special characters depending on the platform.
|
|
25
|
-
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
|
26
|
-
*/
|
|
27
|
-
declare const escapePath: (path: string) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Checks if a pattern has dynamic parts.
|
|
30
|
-
*
|
|
31
|
-
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
|
|
32
|
-
*
|
|
33
|
-
* - Doesn't necessarily return `false` on patterns that include `\`.
|
|
34
|
-
* - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
|
|
35
|
-
* - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
|
|
36
|
-
* - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
|
|
37
|
-
*
|
|
38
|
-
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
|
39
|
-
*/
|
|
40
|
-
declare function isDynamicPattern(pattern: string, options?: {
|
|
41
|
-
caseSensitiveMatch: boolean;
|
|
42
|
-
}): boolean; //#endregion
|
|
43
|
-
//#region src/index.d.ts
|
|
17
|
+
//#region node_modules/.pnpm/tinyglobby@0.2.16/node_modules/tinyglobby/dist/index.d.mts
|
|
18
|
+
//#region src/types.d.ts
|
|
19
|
+
type FileSystemAdapter = Partial<FSLike>;
|
|
44
20
|
interface GlobOptions$1 {
|
|
45
21
|
/**
|
|
46
22
|
* Whether to return absolute paths. Disable to have relative paths.
|
|
@@ -134,8 +110,35 @@ interface GlobOptions$1 {
|
|
|
134
110
|
* @default undefined
|
|
135
111
|
*/
|
|
136
112
|
signal?: AbortSignal;
|
|
137
|
-
}
|
|
138
|
-
|
|
113
|
+
} //#endregion
|
|
114
|
+
//#region src/utils.d.ts
|
|
115
|
+
/**
|
|
116
|
+
* Converts a path to a pattern depending on the platform.
|
|
117
|
+
* Identical to {@link escapePath} on POSIX systems.
|
|
118
|
+
* @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
|
|
119
|
+
*/
|
|
120
|
+
declare const convertPathToPattern: (path: string) => string;
|
|
121
|
+
/**
|
|
122
|
+
* Escapes a path's special characters depending on the platform.
|
|
123
|
+
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
|
124
|
+
*/
|
|
125
|
+
declare const escapePath: (path: string) => string;
|
|
126
|
+
/**
|
|
127
|
+
* Checks if a pattern has dynamic parts.
|
|
128
|
+
*
|
|
129
|
+
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
|
|
130
|
+
*
|
|
131
|
+
* - Doesn't necessarily return `false` on patterns that include `\`.
|
|
132
|
+
* - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
|
|
133
|
+
* - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
|
|
134
|
+
* - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
|
|
135
|
+
*
|
|
136
|
+
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
|
137
|
+
*/
|
|
138
|
+
declare function isDynamicPattern(pattern: string, options?: {
|
|
139
|
+
caseSensitiveMatch: boolean;
|
|
140
|
+
}): boolean; //#endregion
|
|
141
|
+
//#region src/index.d.ts
|
|
139
142
|
/**
|
|
140
143
|
* Asynchronously match files following a glob pattern.
|
|
141
144
|
* @see {@link https://superchupu.dev/tinyglobby/documentation#glob}
|
|
@@ -156,130 +159,454 @@ declare function globSync(options: GlobOptions): string[];
|
|
|
156
159
|
//#region src/fs/types.d.ts
|
|
157
160
|
type PathLike = string | URL;
|
|
158
161
|
interface BufferEncodingOptions {
|
|
159
|
-
encoding
|
|
162
|
+
encoding: "buffer";
|
|
160
163
|
}
|
|
161
164
|
interface StringEncodingOptions {
|
|
162
|
-
encoding?: BufferEncoding
|
|
165
|
+
encoding?: BufferEncoding;
|
|
163
166
|
}
|
|
164
167
|
type AppendFileOptions = StringEncodingOptions & {
|
|
165
|
-
newline?: boolean
|
|
168
|
+
newline?: boolean;
|
|
166
169
|
};
|
|
167
170
|
type WriteJsonOptions = (StringEncodingOptions & {
|
|
168
|
-
indent?: number
|
|
171
|
+
indent?: number;
|
|
169
172
|
}) | number;
|
|
170
173
|
interface MkdirOptions {
|
|
171
|
-
recursive?: boolean
|
|
174
|
+
recursive?: boolean;
|
|
172
175
|
}
|
|
173
176
|
interface RmOptions {
|
|
174
|
-
force?: boolean
|
|
175
|
-
recursive?: boolean
|
|
177
|
+
force?: boolean;
|
|
178
|
+
recursive?: boolean;
|
|
176
179
|
}
|
|
177
180
|
interface CpOptions {
|
|
178
|
-
recursive?: boolean
|
|
181
|
+
recursive?: boolean;
|
|
179
182
|
}
|
|
180
183
|
//#endregion
|
|
181
|
-
//#region src/fs/
|
|
184
|
+
//#region src/fs/vfile.d.ts
|
|
185
|
+
interface PathnameGetter<T> {
|
|
186
|
+
/**
|
|
187
|
+
* @example
|
|
188
|
+
* ```js
|
|
189
|
+
* vfile.pathname(); // "/home/user/project/src/page/index.js"
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
(): string;
|
|
193
|
+
/**
|
|
194
|
+
* @example
|
|
195
|
+
* ```js
|
|
196
|
+
* vfile.pathname("/home/user/project/src/page/index.js");
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
(pathname: string): T;
|
|
200
|
+
/**
|
|
201
|
+
* @example
|
|
202
|
+
* ```js
|
|
203
|
+
* vfile.pathname.relative(); // "src/page/index.js"
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
relative(): string;
|
|
207
|
+
/**
|
|
208
|
+
* @example
|
|
209
|
+
* ```js
|
|
210
|
+
* vfile.pathname.relative("src/page/index.js");
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
relative(pathname: string): T;
|
|
214
|
+
}
|
|
215
|
+
interface DirnameGetter<T> {
|
|
216
|
+
/**
|
|
217
|
+
* @example
|
|
218
|
+
* ```js
|
|
219
|
+
* vfile.dirname(); // "src/page"
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
(): string;
|
|
223
|
+
/**
|
|
224
|
+
* @example
|
|
225
|
+
* ```js
|
|
226
|
+
* vfile.dirname("src/page");
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
(dirname: string): T;
|
|
230
|
+
/**
|
|
231
|
+
* @example
|
|
232
|
+
* ```js
|
|
233
|
+
* vfile.dirname.absolute(); // "/home/user/project/src/page"
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
absolute(): string;
|
|
237
|
+
/**
|
|
238
|
+
* @example
|
|
239
|
+
* ```js
|
|
240
|
+
* vfile.dirname.absolute("/home/user/project/src/page");
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
absolute(dirname: string): T;
|
|
244
|
+
}
|
|
245
|
+
declare class BaseVFile {
|
|
246
|
+
protected _cwd: string;
|
|
247
|
+
protected _dirname: string;
|
|
248
|
+
protected _filename: string;
|
|
249
|
+
protected _extname: string;
|
|
250
|
+
/**
|
|
251
|
+
* @example
|
|
252
|
+
* ```js
|
|
253
|
+
* const vfile = new VFile(
|
|
254
|
+
* "/home/user/project/src/page/index.js",
|
|
255
|
+
* "/home/user/project",
|
|
256
|
+
* );
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
constructor(filepath: PathLike, cwd?: string);
|
|
260
|
+
/**
|
|
261
|
+
* @example
|
|
262
|
+
* ```js
|
|
263
|
+
* vfile.cwd(); // "/home/user/project"
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
cwd(): string;
|
|
267
|
+
/**
|
|
268
|
+
* @example
|
|
269
|
+
* ```js
|
|
270
|
+
* vfile.cwd("/home/user/project");
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
cwd(cwd: string): this;
|
|
274
|
+
get pathname(): PathnameGetter<this>;
|
|
275
|
+
get dirname(): DirnameGetter<this>;
|
|
276
|
+
/**
|
|
277
|
+
* @example
|
|
278
|
+
* ```js
|
|
279
|
+
* vfile.filename(); // "index"
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
filename(): string;
|
|
283
|
+
/**
|
|
284
|
+
* @example
|
|
285
|
+
* ```js
|
|
286
|
+
* vfile.filename("index");
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
filename(filename: string): this;
|
|
290
|
+
/**
|
|
291
|
+
* @example
|
|
292
|
+
* ```js
|
|
293
|
+
* vfile.extname(); // "js"
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
extname(): string;
|
|
297
|
+
/**
|
|
298
|
+
* @example
|
|
299
|
+
* ```js
|
|
300
|
+
* vfile.extname("js");
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
extname(extname: string): this;
|
|
304
|
+
/**
|
|
305
|
+
* @example
|
|
306
|
+
* ```js
|
|
307
|
+
* vfile.basename(); // "index.js"
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
basename(): string;
|
|
311
|
+
/**
|
|
312
|
+
* @example
|
|
313
|
+
* ```js
|
|
314
|
+
* vfile.basename("index.js");
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
basename(basename: string): this;
|
|
318
|
+
clone(): BaseVFile;
|
|
319
|
+
protected absolutePathname(pathname?: string): string | this;
|
|
320
|
+
protected relativePathname(pathname?: string): string | this;
|
|
321
|
+
protected relativeDirname(dirname?: string): string | this;
|
|
322
|
+
protected absoluteDirname(dirname?: string): string | this;
|
|
323
|
+
}
|
|
324
|
+
declare class ExtendVFile<T> extends BaseVFile {
|
|
325
|
+
protected _encoding: BufferEncoding;
|
|
326
|
+
protected _linebreak: string;
|
|
327
|
+
protected _transformer?: {
|
|
328
|
+
parse: (raw: string) => any;
|
|
329
|
+
stringify: (value: T) => any;
|
|
330
|
+
};
|
|
331
|
+
protected _raw: string | any;
|
|
332
|
+
protected _value: T | any;
|
|
333
|
+
/**
|
|
334
|
+
* @example
|
|
335
|
+
* ```js
|
|
336
|
+
* vfile.encoding(); // "utf-8"
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
encoding(): typeof this._encoding;
|
|
340
|
+
/**
|
|
341
|
+
* @example
|
|
342
|
+
* ```js
|
|
343
|
+
* vfile.encoding("utf-8");
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
encoding(encoding: StringEncodingOptions["encoding"]): this;
|
|
347
|
+
/**
|
|
348
|
+
* @example
|
|
349
|
+
* ```js
|
|
350
|
+
* vfile.linebreak(); // "\n"
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
linebreak(): typeof this._linebreak;
|
|
354
|
+
/**
|
|
355
|
+
* @example
|
|
356
|
+
* ```js
|
|
357
|
+
* vfile.linebreak("\r\n");
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
linebreak(linebreak: string): this;
|
|
361
|
+
clone(): ExtendVFile<T>;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/fs/safe/append.d.ts
|
|
182
365
|
declare const appendFile$1: (path: PathLike, data: string, options?: AppendFileOptions) => Promise<Result<void, Error>>;
|
|
183
366
|
declare const appendFileSync$1: (path: PathLike, data: string, options?: AppendFileOptions) => Result<void, Error>;
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/fs/safe/cp.d.ts
|
|
184
369
|
declare const cp$1: (source: PathLike, destination: PathLike, options?: CpOptions) => Promise<Result<void, Error>>;
|
|
185
370
|
declare const cpSync$1: (source: PathLike, destination: PathLike, options?: CpOptions) => Result<void, Error>;
|
|
186
|
-
|
|
187
|
-
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/fs/safe/exists.d.ts
|
|
373
|
+
declare const exists: (path: PathLike) => Promise<boolean>;
|
|
374
|
+
declare const existsSync: (path: PathLike) => boolean;
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/fs/safe/mkdir.d.ts
|
|
188
377
|
declare const mkdir$1: (path: PathLike, options?: MkdirOptions) => Promise<Result<void, Error>>;
|
|
189
378
|
declare const mkdirSync$1: (path: PathLike, options?: MkdirOptions) => Result<void, Error>;
|
|
379
|
+
//#endregion
|
|
380
|
+
//#region src/fs/safe/read.d.ts
|
|
190
381
|
declare function readFile$1(path: PathLike, options: BufferEncodingOptions): Promise<Result<Buffer, Error>>;
|
|
191
382
|
declare function readFile$1(path: PathLike, options?: StringEncodingOptions): Promise<Result<string, Error>>;
|
|
192
383
|
declare function readFileSync$1(path: PathLike, options: BufferEncodingOptions): Result<Buffer, Error>;
|
|
193
384
|
declare function readFileSync$1(path: PathLike, options?: StringEncodingOptions): Result<string, Error>;
|
|
194
|
-
declare const readFileByLine$1: (path: PathLike, options?: StringEncodingOptions) => Promise<Result<AsyncIterable<string>, Error>>;
|
|
195
385
|
declare const readJson$1: <T = any>(path: PathLike, options?: StringEncodingOptions) => Promise<Result<T, Error>>;
|
|
196
386
|
declare const readJsonSync$1: <T = any>(path: PathLike, options?: StringEncodingOptions) => Result<T, Error>;
|
|
387
|
+
declare const readFileByLine$1: (path: PathLike, options?: StringEncodingOptions) => Promise<Result<AsyncIterable<string>, Error>>;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/fs/safe/rm.d.ts
|
|
197
390
|
declare const rm$1: (path: PathLike, options?: RmOptions) => Promise<Result<void, Error>>;
|
|
198
391
|
declare const rmSync$1: (path: PathLike, options?: RmOptions) => Result<void, Error>;
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/fs/safe/write.d.ts
|
|
199
394
|
declare const writeFile: (path: PathLike, data: string, options?: StringEncodingOptions) => Promise<Result<void, Error>>;
|
|
200
395
|
declare const writeFileSync: (path: PathLike, data: string, options?: StringEncodingOptions) => Result<void, Error>;
|
|
201
396
|
declare const writeJson: (path: PathLike, data: any, indentOrOptions?: WriteJsonOptions) => Promise<Result<void, Error>>;
|
|
202
397
|
declare const writeJsonSync: (path: PathLike, data: any, indentOrOptions?: WriteJsonOptions) => Result<void, Error>;
|
|
203
398
|
//#endregion
|
|
204
|
-
//#region src/fs/
|
|
399
|
+
//#region src/fs/safe/vfile.d.ts
|
|
400
|
+
declare class VFile<T = string, PE = Error, SE = Error> extends ExtendVFile<T> {
|
|
401
|
+
protected _transformer?: {
|
|
402
|
+
parse: (raw: string) => Result<T, PE>;
|
|
403
|
+
stringify: (value: T) => Result<string, SE>;
|
|
404
|
+
};
|
|
405
|
+
protected _raw: string;
|
|
406
|
+
protected _value: T;
|
|
407
|
+
/**
|
|
408
|
+
* @example
|
|
409
|
+
* ```js
|
|
410
|
+
* vfile.transformer(); // { parse: [Function], stringify: [Function] }
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
transformer(): typeof this._transformer;
|
|
414
|
+
/**
|
|
415
|
+
* @example
|
|
416
|
+
* ```js
|
|
417
|
+
* vfile.transformer({ parse: [Function], stringify: [Function] });
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
transformer(transformer: typeof this._transformer): this;
|
|
421
|
+
/**
|
|
422
|
+
* @example
|
|
423
|
+
* ```js
|
|
424
|
+
* vfile.transformer("json");
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
transformer(transformer: "json", indent?: number): VFile<T, InferErrType<ReturnType<typeof parse>>, InferErrType<ReturnType<typeof stringify>>>;
|
|
428
|
+
/**
|
|
429
|
+
* @example
|
|
430
|
+
* ```js
|
|
431
|
+
* vfile.raw(); // '["hello", "world"]'
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
raw(): Result<string, SE>;
|
|
435
|
+
/**
|
|
436
|
+
* @example
|
|
437
|
+
* ```js
|
|
438
|
+
* vfile.raw('["hello", "world"]');
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
raw(raw: string): this;
|
|
442
|
+
/**
|
|
443
|
+
* @example
|
|
444
|
+
* ```js
|
|
445
|
+
* vfile.value(); // ["hello", "world"]
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
value(): Result<T, PE>;
|
|
449
|
+
/**
|
|
450
|
+
* @example
|
|
451
|
+
* ```js
|
|
452
|
+
* vfile.value(["hello", "world"]);
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
value(value: T): this;
|
|
456
|
+
/**
|
|
457
|
+
* @example
|
|
458
|
+
* ```js
|
|
459
|
+
* vfile.lines(); // ['["hello", "world"]']
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
lines(): Result<string[], SE>;
|
|
463
|
+
/**
|
|
464
|
+
* @example
|
|
465
|
+
* ```js
|
|
466
|
+
* vfile.append({ hello: "world" });
|
|
467
|
+
* ```
|
|
468
|
+
* @example
|
|
469
|
+
* ```js
|
|
470
|
+
* vfile.append({ hello: "world" }, false);
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
append(value: T, newline?: boolean): Result<void, SE>;
|
|
474
|
+
exists(): ReturnType<typeof exists>;
|
|
475
|
+
existsSync(): ReturnType<typeof existsSync>;
|
|
476
|
+
cp(destination: PathLike, options?: CpOptions): ReturnType<typeof cp$1>;
|
|
477
|
+
cpSync(destination: PathLike, options?: CpOptions): ReturnType<typeof cpSync$1>;
|
|
478
|
+
rm(options?: RmOptions): ReturnType<typeof rm$1>;
|
|
479
|
+
rmSync(options?: RmOptions): ReturnType<typeof rmSync$1>;
|
|
480
|
+
read(): Promise<Result<T, PE | InferErrType<Awaited<ReturnType<typeof readFile$1>>>>>;
|
|
481
|
+
readSync(): Result<T, PE | InferErrType<ReturnType<typeof readFileSync$1>>>;
|
|
482
|
+
readByLine(): ReturnType<typeof readFileByLine$1>;
|
|
483
|
+
write(): Promise<Result<void, SE | InferErrType<Awaited<ReturnType<typeof writeFile>>>>>;
|
|
484
|
+
writeSync(): Result<void, SE | InferErrType<ReturnType<typeof writeFileSync>>>;
|
|
485
|
+
private get encodingOptions();
|
|
486
|
+
protected parseRaw(raw: string): Result<T, PE>;
|
|
487
|
+
protected stringifyValue(value: T): Result<string, SE>;
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/fs/unsafe/append.d.ts
|
|
205
491
|
declare const appendFile: (path: PathLike, data: string, options?: AppendFileOptions) => Promise<void>;
|
|
206
492
|
declare const appendFileSync: (path: PathLike, data: string, options?: AppendFileOptions) => void;
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/fs/unsafe/cp.d.ts
|
|
207
495
|
declare const cp: (source: PathLike, destination: PathLike, options?: CpOptions) => Promise<void>;
|
|
208
496
|
declare const cpSync: (source: PathLike, destination: PathLike, options?: CpOptions) => void;
|
|
209
|
-
|
|
210
|
-
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/fs/unsafe/mkdir.d.ts
|
|
211
499
|
declare const mkdir: (path: PathLike, options?: MkdirOptions) => Promise<void>;
|
|
212
500
|
declare const mkdirSync: (path: PathLike, options?: MkdirOptions) => void;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
declare function
|
|
216
|
-
declare function
|
|
217
|
-
declare
|
|
218
|
-
declare
|
|
219
|
-
declare const
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region src/fs/unsafe/read.d.ts
|
|
503
|
+
declare function readFile(path: PathLike, options: BufferEncodingOptions): Promise<Buffer | Nil>;
|
|
504
|
+
declare function readFile(path: PathLike, options?: StringEncodingOptions): Promise<string | Nil>;
|
|
505
|
+
declare function readFileSync(path: PathLike, options: BufferEncodingOptions): Buffer | Nil;
|
|
506
|
+
declare function readFileSync(path: PathLike, options?: StringEncodingOptions): string | Nil;
|
|
507
|
+
declare const readJson: <T = any>(path: PathLike, options?: StringEncodingOptions) => Promise<T | Nil>;
|
|
508
|
+
declare const readJsonSync: <T = any>(path: PathLike, options?: StringEncodingOptions) => T | Nil;
|
|
509
|
+
declare const readFileByLine: (path: PathLike, options?: StringEncodingOptions) => Promise<AsyncIterable<string> | null>;
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/fs/unsafe/rm.d.ts
|
|
220
512
|
declare const rm: (path: PathLike, options?: RmOptions) => Promise<void>;
|
|
221
513
|
declare const rmSync: (path: PathLike, options?: RmOptions) => void;
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/fs/unsafe/write.d.ts
|
|
222
516
|
declare const writeFile$1: (path: PathLike, data: string, options?: StringEncodingOptions) => Promise<void>;
|
|
223
517
|
declare const writeFileSync$1: (path: PathLike, data: string, options?: StringEncodingOptions) => void;
|
|
224
518
|
declare const writeJson$1: (path: PathLike, data: any, indentOrOptions?: WriteJsonOptions) => Promise<void>;
|
|
225
519
|
declare const writeJsonSync$1: (path: PathLike, data: any, indentOrOptions?: WriteJsonOptions) => void;
|
|
226
520
|
//#endregion
|
|
227
|
-
//#region src/fs/vfile.d.ts
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
content: string;
|
|
521
|
+
//#region src/fs/unsafe/vfile.d.ts
|
|
522
|
+
declare class VFile$1<T = string> extends ExtendVFile<T> {
|
|
523
|
+
protected _transformer?: {
|
|
524
|
+
parse: (raw: string) => T | Nil;
|
|
525
|
+
stringify: (value: T) => string | Nil;
|
|
526
|
+
};
|
|
527
|
+
protected _raw: string | Nil;
|
|
528
|
+
protected _value: T | Nil;
|
|
236
529
|
/**
|
|
237
530
|
* @example
|
|
238
|
-
*
|
|
531
|
+
* ```js
|
|
532
|
+
* vfile.transformer(); // { parse: [Function], stringify: [Function] }
|
|
533
|
+
* ```
|
|
239
534
|
*/
|
|
240
|
-
|
|
535
|
+
transformer(): typeof this._transformer;
|
|
241
536
|
/**
|
|
242
537
|
* @example
|
|
243
|
-
*
|
|
538
|
+
* ```js
|
|
539
|
+
* vfile.transformer({ parse: [Function], stringify: [Function] });
|
|
540
|
+
* ```
|
|
244
541
|
*/
|
|
245
|
-
|
|
542
|
+
transformer(transformer: typeof this._transformer): this;
|
|
246
543
|
/**
|
|
247
544
|
* @example
|
|
248
|
-
*
|
|
545
|
+
* ```js
|
|
546
|
+
* vfile.transformer("json");
|
|
547
|
+
* ```
|
|
249
548
|
*/
|
|
250
|
-
|
|
549
|
+
transformer(transformer: "json", indent?: number): this;
|
|
251
550
|
/**
|
|
252
551
|
* @example
|
|
253
|
-
*
|
|
552
|
+
* ```js
|
|
553
|
+
* vfile.raw(); // '["hello", "world"]'
|
|
554
|
+
* ```
|
|
254
555
|
*/
|
|
255
|
-
|
|
256
|
-
constructor(options: VFileOptions);
|
|
556
|
+
raw(): string | Nil;
|
|
257
557
|
/**
|
|
258
558
|
* @example
|
|
259
|
-
*
|
|
559
|
+
* ```js
|
|
560
|
+
* vfile.raw('["hello", "world"]');
|
|
561
|
+
* ```
|
|
260
562
|
*/
|
|
261
|
-
|
|
262
|
-
set pathname(value: string);
|
|
563
|
+
raw(raw: string): this;
|
|
263
564
|
/**
|
|
264
565
|
* @example
|
|
265
|
-
*
|
|
566
|
+
* ```js
|
|
567
|
+
* vfile.value(); // ["hello", "world"]
|
|
568
|
+
* ```
|
|
266
569
|
*/
|
|
267
|
-
|
|
268
|
-
set basename(value: string);
|
|
570
|
+
value(): T | Nil;
|
|
269
571
|
/**
|
|
270
572
|
* @example
|
|
271
|
-
*
|
|
573
|
+
* ```js
|
|
574
|
+
* vfile.value(["hello", "world"]);
|
|
575
|
+
* ```
|
|
272
576
|
*/
|
|
273
|
-
|
|
274
|
-
set absoluteDirname(value: string);
|
|
577
|
+
value(value: T): this;
|
|
275
578
|
/**
|
|
276
579
|
* @example
|
|
277
|
-
*
|
|
580
|
+
* ```js
|
|
581
|
+
* vfile.lines(); // ['["hello", "world"]']
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
lines(): string[];
|
|
585
|
+
/**
|
|
586
|
+
* @example
|
|
587
|
+
* ```js
|
|
588
|
+
* vfile.append({ hello: "world" });
|
|
589
|
+
* ```
|
|
590
|
+
* @example
|
|
591
|
+
* ```js
|
|
592
|
+
* vfile.append({ hello: "world" }, false);
|
|
593
|
+
* ```
|
|
278
594
|
*/
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
595
|
+
append(value: T, newline?: boolean): void;
|
|
596
|
+
exists(): ReturnType<typeof exists>;
|
|
597
|
+
existsSync(): ReturnType<typeof existsSync>;
|
|
598
|
+
cp(destination: PathLike, options?: CpOptions): ReturnType<typeof cp>;
|
|
599
|
+
cpSync(destination: PathLike, options?: CpOptions): ReturnType<typeof cpSync>;
|
|
600
|
+
rm(options?: RmOptions): ReturnType<typeof rm>;
|
|
601
|
+
rmSync(options?: RmOptions): ReturnType<typeof rmSync>;
|
|
602
|
+
read(): Promise<T | Nil>;
|
|
603
|
+
readSync(): T | Nil;
|
|
604
|
+
readByLine(): ReturnType<typeof readFileByLine>;
|
|
605
|
+
write(): ReturnType<typeof writeFile$1>;
|
|
606
|
+
writeSync(): ReturnType<typeof writeFileSync$1>;
|
|
607
|
+
private get encodingOptions();
|
|
608
|
+
protected parseRaw(raw: string): T | any;
|
|
609
|
+
protected stringifyValue(value: T): string | any;
|
|
283
610
|
}
|
|
284
611
|
//#endregion
|
|
285
|
-
export { type AppendFileOptions, type BufferEncodingOptions, type CpOptions, type
|
|
612
|
+
export { type AppendFileOptions, BaseVFile, type BufferEncodingOptions, type CpOptions, type GlobOptions, type MkdirOptions, type RmOptions, VFile as SafeVFile, type StringEncodingOptions, VFile$1 as VFile, type WriteJsonOptions, appendFile, appendFileSync, convertPathToPattern, cp, cpSync, escapePath, exists, exists as safeExists, existsSync, existsSync as safeExistsSync, glob, globSync, isDynamicPattern, mkdir, mkdirSync, readFile, readFileByLine, readFileSync, readJson, readJsonSync, rm, rmSync, appendFile$1 as safeAppendFile, appendFileSync$1 as safeAppendFileSync, cp$1 as safeCp, cpSync$1 as safeCpSync, mkdir$1 as safeMkdir, mkdirSync$1 as safeMkdirSync, readFile$1 as safeReadFile, readFileByLine$1 as safeReadFileByLine, readFileSync$1 as safeReadFileSync, readJson$1 as safeReadJson, readJsonSync$1 as safeReadJsonSync, rm$1 as safeRm, rmSync$1 as safeRmSync, writeFile as safeWriteFile, writeFileSync as safeWriteFileSync, writeJson as safeWriteJson, writeJsonSync as safeWriteJsonSync, writeFile$1 as writeFile, writeFileSync$1 as writeFileSync, writeJson$1 as writeJson, writeJsonSync$1 as writeJsonSync };
|