@d0paminedriven/fs 10.1.0 → 11.0.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.
- package/dist/docs/index.d.ts +119 -0
- package/dist/docs/index.js +1027 -0
- package/dist/extract/client.d.ts +54 -0
- package/dist/extract/client.js +118 -0
- package/dist/extract/index.d.ts +69 -0
- package/dist/extract/index.js +622 -0
- package/dist/fs/index.d.ts +19 -55
- package/dist/fs/index.js +88 -19
- package/dist/fs-atomic/index.d.ts +28 -36
- package/dist/fs-atomic/index.js +88 -13
- package/dist/fs-base/index.d.ts +105 -111
- package/dist/fs-base/index.js +188 -12
- package/dist/fs-core/index.d.ts +20 -24
- package/dist/fs-core/index.js +44 -16
- package/dist/fs-fetch/index.d.ts +48 -62
- package/dist/fs-fetch/index.js +146 -18
- package/dist/fs-size/index.d.ts +16 -28
- package/dist/fs-size/index.js +64 -15
- package/dist/fs-tmp/index.d.ts +179 -192
- package/dist/fs-tmp/index.js +321 -17
- package/dist/images/index.d.ts +447 -0
- package/dist/images/index.js +899 -0
- package/dist/images/workup.d.ts +30 -0
- package/dist/images/workup.js +317 -0
- package/dist/index.d.ts +20 -22
- package/dist/index.js +20 -64
- package/dist/ld/index.d.ts +15 -13
- package/dist/ld/index.js +56 -6
- package/dist/mime/index.d.ts +299 -294
- package/dist/mime/index.js +348 -13
- package/dist/mixins/index.d.ts +34 -0
- package/dist/mixins/index.js +54 -0
- package/dist/types/index.d.ts +279 -215
- package/dist/types/index.js +11 -6
- package/dist/types/stream.d.ts +6 -4
- package/dist/types/stream.js +1 -1
- package/dist/url/index.d.ts +15 -18
- package/dist/url/index.js +21 -8
- package/dist/utils/index.d.ts +19 -23
- package/dist/utils/index.js +82 -7
- package/package.json +33 -13
- package/dist/chunk-4D2YBCI6.js +0 -163
- package/dist/chunk-5CACVZVF.js +0 -386
- package/dist/chunk-5H6GE5AO.js +0 -14
- package/dist/chunk-7QVYU63E.js +0 -7
- package/dist/chunk-DNR5ZI2T.js +0 -75
- package/dist/chunk-JZ6JNZZ6.js +0 -77
- package/dist/chunk-L2QMQOEJ.js +0 -366
- package/dist/chunk-NJHN5OE3.js +0 -33
- package/dist/chunk-OHKRQJZH.js +0 -82
- package/dist/chunk-OT5JEQKW.js +0 -139
- package/dist/chunk-PATMSIQK.js +0 -367
- package/dist/chunk-PB5A7ZFD.js +0 -79
- package/dist/chunk-VDKUXJE7.js +0 -240
- package/dist/chunk-Y5QWE4EG.js +0 -1335
- package/dist/chunk-YRCJWFZD.js +0 -107
- package/dist/image/index.d.ts +0 -182
- package/dist/image/index.js +0 -13
- package/dist/image/workup.d.ts +0 -40
- package/dist/image/workup.js +0 -12
package/dist/fs/index.js
CHANGED
|
@@ -1,21 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { FsFetch } from "../fs-fetch/index.js";
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
3
|
+
import { relative, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/fs/index.ts
|
|
6
|
+
var Fs = class extends FsFetch {
|
|
7
|
+
constructor(cwd) {
|
|
8
|
+
super(cwd ??= process.cwd());
|
|
9
|
+
this.cwd = cwd;
|
|
10
|
+
}
|
|
11
|
+
async getSpecs(filePath, size = 4096 * 36) {
|
|
12
|
+
if (URL.canParse(filePath)) return await this.extractRemote(filePath, size);
|
|
13
|
+
else {
|
|
14
|
+
const stream = createReadStream(relative(this.cwd, filePath), { highWaterMark: size });
|
|
15
|
+
const buffer = await this.readBytes(stream, size);
|
|
16
|
+
return await this.extractRemote(buffer, size);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async getSpecsFlexi(target, size = 4096 * 36) {
|
|
20
|
+
if (Buffer.isBuffer(target)) return this.extractRemote(target, size);
|
|
21
|
+
else if (URL.canParse(target)) return await this.extractRemote(target, size);
|
|
22
|
+
else {
|
|
23
|
+
const stream = createReadStream(relative(this.cwd, target), { highWaterMark: size });
|
|
24
|
+
const buffer = await this.readBytes(stream, size);
|
|
25
|
+
return this.extractRemote(buffer, size);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async getSpecsTmp(filename, size = 4096 * 36) {
|
|
29
|
+
const rs = createReadStream(resolve(this.tmpDir, filename));
|
|
30
|
+
const arr = Array.of();
|
|
31
|
+
const iterate = rs.iterator();
|
|
32
|
+
for await (const chunk of iterate) arr.push(chunk);
|
|
33
|
+
const buffer = Buffer.concat(arr);
|
|
34
|
+
return await this.extractRemote(buffer, size);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Extract image metadata using streaming (only reads ~4KB)
|
|
38
|
+
* Much more memory efficient for large images
|
|
39
|
+
*/
|
|
40
|
+
async getSpecsStream(filePath, size = 4096 * 36) {
|
|
41
|
+
const stream = createReadStream(relative(this.cwd, filePath), { highWaterMark: size });
|
|
42
|
+
const buffer = await this.readBytes(stream, size);
|
|
43
|
+
return await this.extractRemote(buffer, size);
|
|
44
|
+
}
|
|
45
|
+
async getSpecsStreamTmp(filename) {
|
|
46
|
+
const rs = createReadStream(resolve(this.tmpDir, filename));
|
|
47
|
+
const arr = Array.of();
|
|
48
|
+
const iterate = rs.iterator();
|
|
49
|
+
for await (const chunk of iterate) arr.push(chunk);
|
|
50
|
+
const buffer = Buffer.concat(arr);
|
|
51
|
+
return await this.extractRemote(buffer);
|
|
52
|
+
}
|
|
53
|
+
async readBytes(stream, size) {
|
|
54
|
+
return new Promise((resolve$1, reject) => {
|
|
55
|
+
const chunks = Array.of();
|
|
56
|
+
let totalBytes = 0;
|
|
57
|
+
const cleanup = () => {
|
|
58
|
+
stream.removeAllListeners();
|
|
59
|
+
stream.destroy();
|
|
60
|
+
};
|
|
61
|
+
stream.on("error", (err) => {
|
|
62
|
+
cleanup();
|
|
63
|
+
reject(err);
|
|
64
|
+
});
|
|
65
|
+
stream.on("data", (chunk) => {
|
|
66
|
+
const bytes = size ?? chunk.length;
|
|
67
|
+
const remaining = bytes - totalBytes;
|
|
68
|
+
if (chunk.length <= remaining) {
|
|
69
|
+
chunks.push(chunk);
|
|
70
|
+
totalBytes += chunk.length;
|
|
71
|
+
} else {
|
|
72
|
+
chunks.push(chunk.subarray(0, remaining));
|
|
73
|
+
totalBytes = bytes;
|
|
74
|
+
}
|
|
75
|
+
if (totalBytes >= bytes) {
|
|
76
|
+
cleanup();
|
|
77
|
+
resolve$1(Buffer.concat(chunks));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
stream.on("end", () => {
|
|
81
|
+
cleanup();
|
|
82
|
+
resolve$1(Buffer.concat(chunks));
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
20
86
|
};
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { Fs as default };
|
|
21
90
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
import { ExecuteCommandProps, MkDirSyncOptions, ReadDirOptions, RmOptions
|
|
2
|
-
import { FsBase } from
|
|
3
|
-
import 'stream';
|
|
4
|
-
import 'fs';
|
|
5
|
-
import 'node:stream';
|
|
6
|
-
import 'stream/web';
|
|
7
|
-
import 'dotenv-expand';
|
|
8
|
-
import '../types/stream.js';
|
|
9
|
-
import '../image/index.js';
|
|
10
|
-
import '@d0paminedriven/metadata';
|
|
11
|
-
import '../image/workup.js';
|
|
12
|
-
import '../mime/index.js';
|
|
13
|
-
import '../url/index.js';
|
|
14
|
-
import '../utils/index.js';
|
|
15
|
-
import '../ld/index.js';
|
|
1
|
+
import { ExecuteCommandProps, MkDirSyncOptions, NoParamCallback, ReadDirOptions, RmOptions } from "../types/index.js";
|
|
2
|
+
import { FsBase } from "../fs-base/index.js";
|
|
16
3
|
|
|
4
|
+
//#region src/fs-atomic/index.d.ts
|
|
17
5
|
declare class FsAtomic extends FsBase {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
6
|
+
cwd: string;
|
|
7
|
+
constructor(cwd: string);
|
|
8
|
+
executeCommand: <const T extends string>({
|
|
9
|
+
command,
|
|
10
|
+
...options
|
|
11
|
+
}: ExecuteCommandProps<T>) => Buffer<ArrayBuffer>;
|
|
12
|
+
mkdirSync<const T extends string>(path: T, options?: MkDirSyncOptions): string | undefined;
|
|
13
|
+
generateDirIfDNE<const T extends string>(path: T, options?: MkDirSyncOptions): string | undefined;
|
|
14
|
+
fileToBuffer: <const T extends string>(path: T) => Buffer<ArrayBuffer>;
|
|
15
|
+
fileToBufferAsync: <const T extends string>(path: T) => Promise<NonSharedBuffer>;
|
|
16
|
+
dirContainsDir<const From extends string, const To extends string>(readDir: From, targetDir: To, options?: ReadDirOptions): boolean;
|
|
17
|
+
rmFile<const FP extends string>(filePath: FP, options?: RmOptions): void;
|
|
18
|
+
/**
|
|
19
|
+
* Removes files and directories (modeled on the standard POSIX `rm` utility).
|
|
20
|
+
* To get a behavior similar to the `rm -rf` Unix command, use options `{ recursive: true, force: true }`.
|
|
21
|
+
* @return Fulfills with `undefined` upon success.
|
|
22
|
+
*/
|
|
23
|
+
rmdir<const D extends string>(dir: D, options?: RmOptions): Promise<void>;
|
|
24
|
+
rmDirSync<const D extends string>(dir: D, options?: RmOptions, callback?: NoParamCallback): void;
|
|
25
|
+
existsTmp(path: string): boolean;
|
|
26
|
+
mkdirTmp(path: string, options?: MkDirSyncOptions): string | undefined;
|
|
27
|
+
generateDirIfDNETmp<const T extends string>(path: T, options?: MkDirSyncOptions): string | undefined;
|
|
28
|
+
rmTmpFile<const V extends string>(filename: V): void;
|
|
38
29
|
}
|
|
39
|
-
|
|
30
|
+
//#endregion
|
|
40
31
|
export { FsAtomic };
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/fs-atomic/index.js
CHANGED
|
@@ -1,15 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
import "
|
|
5
|
-
import "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { FsBase } from "../fs-base/index.js";
|
|
2
|
+
import fsSync from "fs";
|
|
3
|
+
import { join, relative, resolve } from "path";
|
|
4
|
+
import fsAsync from "fs/promises";
|
|
5
|
+
import { execSync } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
//#region src/fs-atomic/index.ts
|
|
8
|
+
var FsAtomic = class extends FsBase {
|
|
9
|
+
constructor(cwd) {
|
|
10
|
+
super(cwd ??= process.cwd());
|
|
11
|
+
this.cwd = cwd;
|
|
12
|
+
}
|
|
13
|
+
executeCommand = ({ command, ...options }) => Buffer.from(execSync(command, { ...options }));
|
|
14
|
+
mkdirSync(path, options = {
|
|
15
|
+
mode: 511,
|
|
16
|
+
recursive: true
|
|
17
|
+
}) {
|
|
18
|
+
return fsSync.mkdirSync(relative(this.cwd, path), options);
|
|
19
|
+
}
|
|
20
|
+
generateDirIfDNE(path, options = {
|
|
21
|
+
mode: 511,
|
|
22
|
+
recursive: true
|
|
23
|
+
}) {
|
|
24
|
+
if (this.exists(path)) return;
|
|
25
|
+
else return this.mkdirSync(path, options);
|
|
26
|
+
}
|
|
27
|
+
fileToBuffer = (path) => Buffer.from(fsSync.readFileSync(relative(this.cwd, path)).toJSON().data);
|
|
28
|
+
fileToBufferAsync = async (path) => {
|
|
29
|
+
return await fsAsync.readFile(relative(this.cwd, path));
|
|
30
|
+
};
|
|
31
|
+
dirContainsDir(readDir, targetDir, options) {
|
|
32
|
+
return this.readDir(readDir, options).filter((t) => t.split(".").length === 1).includes(targetDir);
|
|
33
|
+
}
|
|
34
|
+
rmFile(filePath, options = {
|
|
35
|
+
force: true,
|
|
36
|
+
maxRetries: 0,
|
|
37
|
+
recursive: true,
|
|
38
|
+
retryDelay: 100
|
|
39
|
+
}) {
|
|
40
|
+
if (this.exists(filePath)) if (this.isRootPathTargeted(filePath)) fsSync.rmSync(resolve(join(this.cwd, filePath)), options);
|
|
41
|
+
else fsSync.rmSync(resolve(this.cwd, filePath), options);
|
|
42
|
+
else return;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Removes files and directories (modeled on the standard POSIX `rm` utility).
|
|
46
|
+
* To get a behavior similar to the `rm -rf` Unix command, use options `{ recursive: true, force: true }`.
|
|
47
|
+
* @return Fulfills with `undefined` upon success.
|
|
48
|
+
*/
|
|
49
|
+
async rmdir(dir, options = {
|
|
50
|
+
maxRetries: 0,
|
|
51
|
+
retryDelay: 100,
|
|
52
|
+
recursive: true,
|
|
53
|
+
force: true
|
|
54
|
+
}) {
|
|
55
|
+
const resolved = relative(this.cwd, dir);
|
|
56
|
+
if (this.exists(dir)) return await fsAsync.rm(relative(this.cwd, dir), options);
|
|
57
|
+
else throw new Error(`directory ${resolved} does not exist`);
|
|
58
|
+
}
|
|
59
|
+
rmDirSync(dir, options = {
|
|
60
|
+
force: true,
|
|
61
|
+
recursive: true,
|
|
62
|
+
maxRetries: 0,
|
|
63
|
+
retryDelay: 100
|
|
64
|
+
}, callback = (err) => err?.message ? console.error(err.message) : console.error(`directory ${dir} does not exist`)) {
|
|
65
|
+
const resolved = resolve(this.cwd, dir);
|
|
66
|
+
if (this.exists(dir)) return fsSync.rm(resolved, options, callback);
|
|
67
|
+
else throw new Error(`directory ${resolved} does not exist`);
|
|
68
|
+
}
|
|
69
|
+
existsTmp(path) {
|
|
70
|
+
return this.exists(resolve(this.tmpDir, path));
|
|
71
|
+
}
|
|
72
|
+
mkdirTmp(path, options = {
|
|
73
|
+
mode: 511,
|
|
74
|
+
recursive: true
|
|
75
|
+
}) {
|
|
76
|
+
return this.mkdirSync(resolve(this.tmpDir, path), options);
|
|
77
|
+
}
|
|
78
|
+
generateDirIfDNETmp(path, options) {
|
|
79
|
+
if (this.existsTmp(path)) return;
|
|
80
|
+
else return this.mkdirTmp(path, options);
|
|
81
|
+
}
|
|
82
|
+
rmTmpFile(filename) {
|
|
83
|
+
const tmpPath = resolve(this.tmpDir, filename);
|
|
84
|
+
this.rmFile(tmpPath);
|
|
85
|
+
}
|
|
14
86
|
};
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { FsAtomic };
|
|
15
90
|
//# sourceMappingURL=index.js.map
|
package/dist/fs-base/index.d.ts
CHANGED
|
@@ -1,114 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import 'stream';
|
|
8
|
-
import 'fs';
|
|
9
|
-
import '@d0paminedriven/metadata';
|
|
10
|
-
import '../image/workup.js';
|
|
11
|
-
import '../mime/index.js';
|
|
12
|
-
import '../url/index.js';
|
|
13
|
-
import '../utils/index.js';
|
|
14
|
-
import '../ld/index.js';
|
|
1
|
+
import { ReadDirOptions } from "../types/index.js";
|
|
2
|
+
import { AsyncIter, Streamable } from "../types/stream.js";
|
|
3
|
+
import { MimeService } from "../mime/index.js";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import { ReadableStream } from "stream/web";
|
|
6
|
+
import expand from "dotenv-expand";
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
8
|
+
//#region src/fs-base/index.d.ts
|
|
9
|
+
declare class FsBase extends MimeService {
|
|
10
|
+
cwd: string;
|
|
11
|
+
constructor(cwd: string);
|
|
12
|
+
get tmpDir(): string;
|
|
13
|
+
get homeDir(): string;
|
|
14
|
+
get platform(): NodeJS.Platform;
|
|
15
|
+
get hostname(): string;
|
|
16
|
+
get devNull(): string;
|
|
17
|
+
get eol(): string;
|
|
18
|
+
private get env();
|
|
19
|
+
parseDotEnv(): expand.DotenvParseOutput | undefined;
|
|
20
|
+
relative(from: string, to: string): string;
|
|
21
|
+
isHomeTargeted(path: string): boolean;
|
|
22
|
+
isRootPathTargeted<const T extends string>(path: T): boolean;
|
|
23
|
+
pathHandler<const T extends string>(path: T): string;
|
|
24
|
+
isUint8Array(v: unknown): v is Uint8Array<ArrayBufferLike>;
|
|
25
|
+
isBuffer(v: unknown): v is Buffer<ArrayBufferLike>;
|
|
26
|
+
isWebReadableStream(v: unknown): v is ReadableStream<any>;
|
|
27
|
+
isAsyncIterable(v: unknown): v is AsyncIter;
|
|
28
|
+
formatHelper<const T extends string>(f: T): string;
|
|
29
|
+
cleanDataUrl<const C extends string>(props: C): string;
|
|
30
|
+
toReadable(data: Streamable): Readable;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param target path to the file or directory to check for existence
|
|
34
|
+
* @returns true if the file or directory exists, false otherwise
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const fs = new Fs(process.cwd());
|
|
38
|
+
* const exists = fs.exists("my-file.txt");
|
|
39
|
+
* console.log(exists); // true if the file exists, false otherwise
|
|
40
|
+
* ```
|
|
41
|
+
* @description
|
|
42
|
+
* This method checks if a file or directory exists at the specified path input
|
|
43
|
+
*
|
|
44
|
+
* Additional Note:
|
|
45
|
+
*
|
|
46
|
+
* say you have a directory that begins with a dot, such as `.turbo`;
|
|
47
|
+
*
|
|
48
|
+
* in this scenario, both `./.turbo` and `.turbo` will return true if the directory exists
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
exists<const T extends string>(target: T): boolean;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param ms milliseconds to wait
|
|
55
|
+
* @returns a promise that resolves after the specified number of milliseconds
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const fs = new Fs(process.cwd());
|
|
59
|
+
* await fs.wait(1000); // waits for 1 second
|
|
60
|
+
* console.log("Done waiting!");
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Alternatively, you can use it like this:
|
|
64
|
+
* ```ts
|
|
65
|
+
* const fs = new Fs(process.cwd());
|
|
66
|
+
* fs.wait(1000).then(() => { // waits for 1 second
|
|
67
|
+
* console.log("Done waiting!");
|
|
68
|
+
* // do something after waiting
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @description
|
|
73
|
+
* This method is useful for delaying execution in asynchronous code, such as when you need to wait for a file operation to complete or when you want to introduce a delay in a loop.
|
|
74
|
+
*/
|
|
75
|
+
wait<T extends number>(ms: T): Promise<unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* Handles an array or readonly array of strings and/or Buffers, converting Buffers to strings
|
|
78
|
+
* @param arr An array or readonly array of strings and/or Buffers
|
|
79
|
+
* @returns An array of strings with Buffers converted to UTF-8 strings.
|
|
80
|
+
*/
|
|
81
|
+
handleBuffStrArrUnion<const T extends (string | Buffer)[] | readonly (string | Buffer)[]>(arr: T): string[];
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param path path to the directory relative to the cwd
|
|
85
|
+
* @param options options for reading the directory, defaults to recursive
|
|
86
|
+
*
|
|
87
|
+
* The following two examples are equivalent:
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const fs = new Fs(process.cwd());
|
|
92
|
+
* const files = fs.readDir("./my-directory", { recursive: true });
|
|
93
|
+
* console.log(files);
|
|
94
|
+
* ```
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const fs = new Fs(process.cwd());
|
|
98
|
+
* const files = fs.readDir("my-directory", { recursive: true });
|
|
99
|
+
* console.log(files);
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @returns an array of strings representing the contents of the directory
|
|
103
|
+
*/
|
|
104
|
+
readDir<const T extends string>(path: T, options?: ReadDirOptions): string[];
|
|
112
105
|
}
|
|
113
|
-
|
|
106
|
+
//#endregion
|
|
114
107
|
export { FsBase };
|
|
108
|
+
//# sourceMappingURL=index.d.ts.map
|