@ix-xs/node-comfort 1.0.4 → 1.0.51
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/index.js +12 -14
- package/package.json +13 -17
- package/src/checker.js +76 -0
- package/src/cli.js +86 -0
- package/{core/FS.js → src/fs.js} +121 -229
- package/src/localStorage.js +242 -0
- package/{core/Logger.js → src/logger.js} +23 -97
- package/src/utils.js +225 -0
- package/core/CLI.js +0 -95
- package/core/Checker.js +0 -127
- package/core/Stepper.js +0 -115
- package/core/Storage.js +0 -348
- package/core/Utils.js +0 -206
- package/tsconfig.json +0 -18
- package/types/core/CLI.d.ts +0 -25
- package/types/core/CLI.d.ts.map +0 -1
- package/types/core/Checker.d.ts +0 -73
- package/types/core/Checker.d.ts.map +0 -1
- package/types/core/FS.d.ts +0 -220
- package/types/core/FS.d.ts.map +0 -1
- package/types/core/Logger.d.ts +0 -253
- package/types/core/Logger.d.ts.map +0 -1
- package/types/core/Stepper.d.ts +0 -49
- package/types/core/Stepper.d.ts.map +0 -1
- package/types/core/Storage.d.ts +0 -111
- package/types/core/Storage.d.ts.map +0 -1
- package/types/core/Utils.d.ts +0 -55
- package/types/core/Utils.d.ts.map +0 -1
- package/types/index.d.ts +0 -175
- package/types/index.d.ts.map +0 -1
package/core/Utils.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
const { config } = require("@dotenvx/dotenvx");
|
|
2
|
-
const { log } = require("./Logger");
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @module Utils
|
|
6
|
-
* @description
|
|
7
|
-
*/
|
|
8
|
-
module.exports = {
|
|
9
|
-
getEnv(env) {
|
|
10
|
-
config({ quiet: true });
|
|
11
|
-
return process.env[env];
|
|
12
|
-
},
|
|
13
|
-
/**
|
|
14
|
-
* Creates a Promise that resolves after specified milliseconds.
|
|
15
|
-
*
|
|
16
|
-
* @param {number} ms - Milliseconds to wait (positive integer).
|
|
17
|
-
* @returns {Promise<void>} Promise that resolves after delay.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // Sequential delays
|
|
21
|
-
* await wait(100); // 100ms
|
|
22
|
-
* await wait(500); // 500ms
|
|
23
|
-
* await wait(2000); // 2 seconds
|
|
24
|
-
*/
|
|
25
|
-
wait(ms) {
|
|
26
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {boolean|Promise<boolean>} predicate
|
|
31
|
-
* @param {*} handler
|
|
32
|
-
* @param {object} [options]
|
|
33
|
-
* @param {number} [options.interval]
|
|
34
|
-
* @param {number|null} [options.timeout]
|
|
35
|
-
* @param {number|null} [options.max]
|
|
36
|
-
*/
|
|
37
|
-
when(predicate, handler, options) {
|
|
38
|
-
const interval = options?.interval ?? 50;
|
|
39
|
-
const timeout = options?.timeout ?? null;
|
|
40
|
-
const max = options?.max ?? null;
|
|
41
|
-
|
|
42
|
-
const listeners = {
|
|
43
|
-
trigger: new Set(),
|
|
44
|
-
error: new Set(),
|
|
45
|
-
timeout: new Set(),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
let _timer = null;
|
|
49
|
-
let _timeoutTimer = null;
|
|
50
|
-
let _stopped = false;
|
|
51
|
-
let _count = 0;
|
|
52
|
-
|
|
53
|
-
function emit(event, payload) {
|
|
54
|
-
for (const fn of listeners[event]) {
|
|
55
|
-
try {
|
|
56
|
-
fn(payload);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.error(`[when] listener error on "${event}":`, error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function evalPredicate() {
|
|
64
|
-
if (typeof predicate === "function") {
|
|
65
|
-
return await predicate();
|
|
66
|
-
}
|
|
67
|
-
return Boolean(predicate);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function tick() {
|
|
71
|
-
if (_stopped) return;
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
const ok = await evalPredicate();
|
|
75
|
-
|
|
76
|
-
if (ok) {
|
|
77
|
-
_count++;
|
|
78
|
-
emit("trigger", handler);
|
|
79
|
-
|
|
80
|
-
if (max != null && _count >= max) {
|
|
81
|
-
_stopInternal();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!_stopped) {
|
|
87
|
-
_timer = setTimeout(tick, interval);
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
emit("error", error);
|
|
91
|
-
if (!_stopped) {
|
|
92
|
-
_timer = setTimeout(tick, interval);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function _stopInternal() {
|
|
98
|
-
_stopped = true;
|
|
99
|
-
if (_timer) {
|
|
100
|
-
clearTimeout(_timer);
|
|
101
|
-
_timer = null;
|
|
102
|
-
}
|
|
103
|
-
if (_timeoutTimer) {
|
|
104
|
-
clearTimeout(_timeoutTimer);
|
|
105
|
-
_timeoutTimer = null;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const api = {
|
|
110
|
-
start() {
|
|
111
|
-
if (_stopped) return api;
|
|
112
|
-
|
|
113
|
-
if (!_timer) {
|
|
114
|
-
_timer = setTimeout(tick, 0);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (timeout != null && !_timeoutTimer) {
|
|
118
|
-
_timeoutTimer = setTimeout(() => {
|
|
119
|
-
if (_stopped) return;
|
|
120
|
-
emit("timeout", handler);
|
|
121
|
-
_stopInternal();
|
|
122
|
-
}, timeout);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return api;
|
|
126
|
-
},
|
|
127
|
-
stop() {
|
|
128
|
-
_stopInternal();
|
|
129
|
-
return api;
|
|
130
|
-
},
|
|
131
|
-
/**
|
|
132
|
-
* @param {"error"|"trigger"|"timeout"} event
|
|
133
|
-
* @param {(payload: any) => void} fn
|
|
134
|
-
*/
|
|
135
|
-
on(event, fn) {
|
|
136
|
-
listeners[event]?.add(fn);
|
|
137
|
-
return api;
|
|
138
|
-
},
|
|
139
|
-
/**
|
|
140
|
-
* @param {"error"|"trigger"|"timeout"} event
|
|
141
|
-
* @param {(payload: any) => void} fn
|
|
142
|
-
*/
|
|
143
|
-
off(event, fn) {
|
|
144
|
-
listeners[event]?.delete(fn);
|
|
145
|
-
return api;
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
return api;
|
|
150
|
-
},
|
|
151
|
-
dontCrash() {
|
|
152
|
-
const defaults = {
|
|
153
|
-
error: (error) => {
|
|
154
|
-
log(
|
|
155
|
-
`<% red [@ix-xs/node-comfort] Process Error %>\n<% gray ${error.stack ?? error} %>`,
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
exit: (code) => {
|
|
159
|
-
log(
|
|
160
|
-
`<% yellow [@ix-xs/node-comfort] Process Exit %>\n→ Code: <% gray ${code} %>`,
|
|
161
|
-
);
|
|
162
|
-
},
|
|
163
|
-
sig: (signal) => {
|
|
164
|
-
log(
|
|
165
|
-
`<% yellow [@ix-xs/node-comfort] Process SIG* %>\n→ Signal: <% gray ${signal} %>`,
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
process.exit(0);
|
|
169
|
-
},
|
|
170
|
-
beforeExit: (code) => {},
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const _ = {
|
|
174
|
-
/**
|
|
175
|
-
* @template { "error" | "exit" | "sig" | "beforeExit" } E
|
|
176
|
-
* @param { E } event
|
|
177
|
-
* @param { { error: (error: Error | unknown) => void | Promise<void>, exit: (code: number) => void | Promise<void>, sig: (signal: "SIGINT" | "SIGTERM" | "SIGQUIT") => void | Promise<void>, beforeExit: (code: number) => void|Promise<void> }[E] } handler
|
|
178
|
-
*/
|
|
179
|
-
on(event, handler) {
|
|
180
|
-
if (event === "error") {
|
|
181
|
-
process.removeAllListeners("uncaughtException");
|
|
182
|
-
process.removeAllListeners("unhandledRejection");
|
|
183
|
-
process.on("uncaughtException", handler ?? defaults.error);
|
|
184
|
-
process.on("unhandledRejection", handler ?? defaults.error);
|
|
185
|
-
} else if (event === "exit") {
|
|
186
|
-
process.removeAllListeners("exit");
|
|
187
|
-
process.on("exit", handler ?? defaults.exit);
|
|
188
|
-
} else if (event === "sig") {
|
|
189
|
-
for (const signal of ["SIGINT", "SIGTERM", "SIGQUIT"]) {
|
|
190
|
-
process.removeAllListeners(signal);
|
|
191
|
-
process.on(signal, handler ?? defaults.sig);
|
|
192
|
-
}
|
|
193
|
-
} else if (event === "beforeExit") {
|
|
194
|
-
process.removeAllListeners("beforeExit");
|
|
195
|
-
process.on("beforeExit", handler ?? defaults.beforeExit);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return _;
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
_.on("error").on("exit").on("sig");
|
|
203
|
-
|
|
204
|
-
return _;
|
|
205
|
-
},
|
|
206
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"allowJs": true,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"emitDeclarationOnly": true,
|
|
8
|
-
"outDir": "types",
|
|
9
|
-
"declarationMap": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"resolveJsonModule": true
|
|
15
|
-
},
|
|
16
|
-
"include": ["**/*"],
|
|
17
|
-
"exclude": ["node_modules", "types"]
|
|
18
|
-
}
|
package/types/core/CLI.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export class cli_stream {
|
|
2
|
-
constructor(command: any, args: any);
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {"error"|"data"|"stopped"} EventName
|
|
5
|
-
* @typedef {{
|
|
6
|
-
* error: (error: Error) => void|Promise<void>,
|
|
7
|
-
* data: (message: string) => void|Promise<void>,
|
|
8
|
-
* stopped: (code: number, signal: keyof import("node:child_process").ChildProcessEventMap) => void|Promise<void>,
|
|
9
|
-
* }} EventHandler
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @template {EventName} E
|
|
13
|
-
* @param {E} event
|
|
14
|
-
* @param {EventHandler[E]} handler
|
|
15
|
-
*/
|
|
16
|
-
on<E extends "data" | "error" | "stopped">(event: E, handler: {
|
|
17
|
-
error: (error: Error) => void | Promise<void>;
|
|
18
|
-
data: (message: string) => void | Promise<void>;
|
|
19
|
-
stopped: (code: number, signal: keyof import("node:child_process").ChildProcessEventMap) => void | Promise<void>;
|
|
20
|
-
}[E]): this;
|
|
21
|
-
stop(): Promise<any>;
|
|
22
|
-
#private;
|
|
23
|
-
}
|
|
24
|
-
export declare function cli_run(command: string): NonSharedBuffer & string;
|
|
25
|
-
//# sourceMappingURL=CLI.d.ts.map
|
package/types/core/CLI.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../core/CLI.js"],"names":[],"mappings":"AAGA;IAIE,qCAqBC;IAED;;;;;;;SAOE;IACF;;;;SAIE;IACF,GAJwB,CAAC,SAAb,4BAAW,SACb,CAAC;eAPF,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC;cACrC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC;iBACpC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,oBAAoB,EAAE,oBAAoB,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC;gBAW/G;IAED,qBA4BC;;CACF;AAUU,yCAFC,MAAM,4BAOf"}
|
package/types/core/Checker.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the value is an array.
|
|
3
|
-
* @param {*} value - The value to check.
|
|
4
|
-
* @returns {boolean} Returns `true` if the value is an array, otherwise `false`.
|
|
5
|
-
*/
|
|
6
|
-
export function isArray(value: any): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Checks if the value is a valid number (not NaN).
|
|
9
|
-
* @param {*} value - The value to check.
|
|
10
|
-
* @returns {boolean} Returns `true` if the value is a valid number, otherwise `false`.
|
|
11
|
-
*/
|
|
12
|
-
export function isNumber(value: any): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Checks if the value is a function.
|
|
15
|
-
* @param {*} value - The value to check.
|
|
16
|
-
* @returns {boolean} Returns `true` if the value is a function, otherwise `false`.
|
|
17
|
-
*/
|
|
18
|
-
export function isFunction(value: any): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if the value is an object (and not `null`).
|
|
21
|
-
* @param {*} value - The value to check.
|
|
22
|
-
* @returns {boolean} Returns `true` if the value is a non-null object, otherwise `false`.
|
|
23
|
-
*/
|
|
24
|
-
export function isObject(value: any): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Checks if the value is a boolean.
|
|
27
|
-
* @param {*} value - The value to check.
|
|
28
|
-
* @returns {boolean} Returns `true` if the value is a boolean, otherwise `false`.
|
|
29
|
-
*/
|
|
30
|
-
export function isBoolean(value: any): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Checks if the value is a string.
|
|
33
|
-
* @param {*} value - The value to check.
|
|
34
|
-
* @returns {boolean} Returns `true` if the value is a string, otherwise `false`.
|
|
35
|
-
*/
|
|
36
|
-
export function isString(value: any): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Checks if the value is `undefined`.
|
|
39
|
-
* @param {*} value - The value to check.
|
|
40
|
-
* @returns {boolean} Returns `true` if the value is `undefined`, otherwise `false`.
|
|
41
|
-
*/
|
|
42
|
-
export function isUndefined(value: any): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the value is `null`.
|
|
45
|
-
* @param {*} value - The value to check.
|
|
46
|
-
* @returns {boolean} Returns `true` if the value is `null`, otherwise `false`.
|
|
47
|
-
*/
|
|
48
|
-
export function isNull(value: any): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Checks if the value is a valid `Date` object.
|
|
51
|
-
* @param {*} value - The value to check.
|
|
52
|
-
* @returns {boolean} Returns `true` if the value is an instance of `Date`, otherwise `false`.
|
|
53
|
-
*/
|
|
54
|
-
export function isDate(value: any): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Checks if the value is a `Map` instance.
|
|
57
|
-
* @param {*} value - The value to check.
|
|
58
|
-
* @returns {boolean} Returns `true` if the value is a Map, otherwise `false`.
|
|
59
|
-
*/
|
|
60
|
-
export function isMap(value: any): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Checks if the value is a `Set` instance.
|
|
63
|
-
* @param {*} value - The value to check.
|
|
64
|
-
* @returns {boolean} Returns `true` if the value is a Set, otherwise `false`.
|
|
65
|
-
*/
|
|
66
|
-
export function isSet(value: any): boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Checks if the value is a native JavaScript error (`Error`, `TypeError`, etc.).
|
|
69
|
-
* @param {*} value - The value to check.
|
|
70
|
-
* @returns {boolean} Returns `true` if the value is a native error, otherwise `false`.
|
|
71
|
-
*/
|
|
72
|
-
export function isError(value: any): boolean;
|
|
73
|
-
//# sourceMappingURL=Checker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Checker.d.ts","sourceRoot":"","sources":["../../core/Checker.js"],"names":[],"mappings":"AAmBE;;;;KAIE;AACF,+BAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,gCAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,kCAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,gCAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,iCAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,gCAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,mCAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,8BAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,8BAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,6BAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,6BAHU,GAAC,GACC,OAAO,CAIlB;AAED;;;;KAIE;AACF,+BAHU,GAAC,GACC,OAAO,CAIlB"}
|
package/types/core/FS.d.ts
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Safely read an environment variable.
|
|
3
|
-
*
|
|
4
|
-
* Loads variables from the default `.env` file (if present) and then
|
|
5
|
-
* returns the value for the given key. When `options.envFile` is provided,
|
|
6
|
-
* the function expects `process.env[options.envFile]` to be an object
|
|
7
|
-
* containing namespaced environment variables (e.g. per environment).
|
|
8
|
-
*
|
|
9
|
-
* @param {string} env - Environment variable name (e.g. "PORT").
|
|
10
|
-
* @param {object} [options] - Optional configuration object.
|
|
11
|
-
* @param {string} [options.envFile] - Name of a namespaced env container under `process.env`.
|
|
12
|
-
* @returns {string|undefined} The environment variable value, or `undefined` if not found.
|
|
13
|
-
*/
|
|
14
|
-
export function getEnv(env: string, options?: {
|
|
15
|
-
envFile?: string;
|
|
16
|
-
}): string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Resolves path relative to caller file or current directory.
|
|
19
|
-
* Supports `./`, `../`, absolute paths, and searches for existing paths.
|
|
20
|
-
* @param {string} [path=process.cwd()] - Path to resolve.
|
|
21
|
-
* @returns {string} Resolved absolute path.
|
|
22
|
-
* @example
|
|
23
|
-
* nodeComfort.createPath("./data/users"); // Resolves from caller file
|
|
24
|
-
*/
|
|
25
|
-
export function createPath(path?: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Returns all folders in path (recursive option).
|
|
28
|
-
* @param {string} [path=process.cwd()] - Starting directory.
|
|
29
|
-
* @param {boolean} [recursive=true] - Include subfolders.
|
|
30
|
-
* @returns {string[]|undefined} Array of folder paths.
|
|
31
|
-
*/
|
|
32
|
-
export function getFoldersIn(path?: string, recursive?: boolean): string[] | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Resolves and returns existing folder path.
|
|
35
|
-
* @param {string} [path=process.cwd()] - Folder path.
|
|
36
|
-
* @returns {string|undefined} Absolute folder path.
|
|
37
|
-
*/
|
|
38
|
-
export function getFolder(path?: string): string | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Returns all files in path (recursive option).
|
|
41
|
-
* @param {string} [path=process.cwd()] - Starting directory.
|
|
42
|
-
* @param {boolean} [recursive=true] - Include subdirectories.
|
|
43
|
-
* @returns {string[]|undefined} Array of file paths.
|
|
44
|
-
*/
|
|
45
|
-
export function getFilesIn(path?: string, recursive?: boolean): string[] | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Resolves and returns existing file path.
|
|
48
|
-
* @param {string} path - File path.
|
|
49
|
-
* @returns {string|undefined} Absolute file path.
|
|
50
|
-
*/
|
|
51
|
-
export function getFile(path: string): string | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* Creates folder (recursive) with force overwrite option.
|
|
54
|
-
* @param {string} path - Folder path to create.
|
|
55
|
-
* @param {boolean} [force=false] - Overwrite if exists.
|
|
56
|
-
* @returns {boolean|undefined} Success status.
|
|
57
|
-
*/
|
|
58
|
-
export function createFolder(path: string, force?: boolean): boolean | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* Creates file with auto-directory creation and content serialization.
|
|
61
|
-
* Supports string, object (→ JSON), null/undefined (→ empty).
|
|
62
|
-
* @param {string} path - File path.
|
|
63
|
-
* @param {boolean} [force=false] - Overwrite if exists.
|
|
64
|
-
* @param {string|object|null|undefined} [data] - File content.
|
|
65
|
-
* @returns {boolean|undefined} Success status.
|
|
66
|
-
* @example
|
|
67
|
-
* nodeComfort.createFile("config.json", false, { apiKey: "secret" });
|
|
68
|
-
*/
|
|
69
|
-
export function createFile(path: string, force?: boolean, data?: string | object | null | undefined): boolean | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Deletes multiple folders matching filter.
|
|
72
|
-
* @param {string} [path=process.cwd()] - Starting directory.
|
|
73
|
-
* @param {(folder: string) => boolean} [filter] - Folder filter function.
|
|
74
|
-
* @returns {number|undefined} Count of deleted folders.
|
|
75
|
-
*/
|
|
76
|
-
export function deleteFoldersIn(path?: string, filter?: (folder: string) => boolean): number | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Deletes folder and all contents recursively.
|
|
79
|
-
* @param {string} path - Folder path.
|
|
80
|
-
* @returns {boolean|undefined} Success status.
|
|
81
|
-
*/
|
|
82
|
-
export function deleteFolder(path: string): boolean | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* Deletes multiple files matching filter.
|
|
85
|
-
* @param {string} [path=process.cwd()] - Starting directory.
|
|
86
|
-
* @param {boolean} [recursive=false] - Search subdirectories.
|
|
87
|
-
* @param {(file: string) => boolean} [filter] - File filter function.
|
|
88
|
-
* @returns {number|undefined} Count of deleted files.
|
|
89
|
-
*/
|
|
90
|
-
export function deleteFilesIn(path?: string, recursive?: boolean, filter?: (file: string) => boolean): number | undefined;
|
|
91
|
-
/**
|
|
92
|
-
* Deletes single file.
|
|
93
|
-
* @param {string} path - File path.
|
|
94
|
-
* @returns {boolean|undefined} Success status.
|
|
95
|
-
*/
|
|
96
|
-
export function deleteFile(path: string): boolean | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Copies multiple folders with optional files and recursive support.
|
|
99
|
-
* @param {Object} options - Copy options.
|
|
100
|
-
* @param {string} options.dest - Destination base path.
|
|
101
|
-
* @param {string} [options.path] - Source path.
|
|
102
|
-
* @param {boolean} [options.recursive=true] - Copy subfolders.
|
|
103
|
-
* @param {boolean} [options.withFiles=false] - Include files.
|
|
104
|
-
* @param {boolean} [options.force=false] - Overwrite existing.
|
|
105
|
-
* @param {(folder: string) => boolean} [options.filter] - Folder filter.
|
|
106
|
-
* @returns {number|undefined} Count of copied folders.
|
|
107
|
-
*/
|
|
108
|
-
export function copyFoldersIn(options: {
|
|
109
|
-
dest: string;
|
|
110
|
-
path?: string;
|
|
111
|
-
recursive?: boolean;
|
|
112
|
-
withFiles?: boolean;
|
|
113
|
-
force?: boolean;
|
|
114
|
-
filter?: (folder: string) => boolean;
|
|
115
|
-
}): number | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* Copies single folder with optional contents.
|
|
118
|
-
* @param {Object} options - Copy options.
|
|
119
|
-
* @param {string} options.dest - Destination path.
|
|
120
|
-
* @param {string} [options.path] - Source path.
|
|
121
|
-
* @param {boolean} [options.recursive=false] - Copy subfolders.
|
|
122
|
-
* @param {boolean} [options.withFiles=false] - Include files.
|
|
123
|
-
* @param {boolean} [options.force=false] - Overwrite existing.
|
|
124
|
-
* @returns {boolean|undefined} Success status.
|
|
125
|
-
*/
|
|
126
|
-
export function copyFolder(options: {
|
|
127
|
-
dest: string;
|
|
128
|
-
path?: string;
|
|
129
|
-
recursive?: boolean;
|
|
130
|
-
withFiles?: boolean;
|
|
131
|
-
force?: boolean;
|
|
132
|
-
}): boolean | undefined;
|
|
133
|
-
/**
|
|
134
|
-
* Copies multiple files with optional recursive structure preservation.
|
|
135
|
-
* @param {Object} options - Copy options.
|
|
136
|
-
* @param {string} options.dest - Destination base path.
|
|
137
|
-
* @param {string} [options.path] - Source path.
|
|
138
|
-
* @param {boolean} [options.recursive=true] - Preserve directory structure.
|
|
139
|
-
* @param {boolean} [options.force=false] - Overwrite existing.
|
|
140
|
-
* @param {(file: string) => boolean} [options.filter] - File filter.
|
|
141
|
-
* @returns {number|undefined} Count of copied files.
|
|
142
|
-
*/
|
|
143
|
-
export function copyFilesIn(options: {
|
|
144
|
-
dest: string;
|
|
145
|
-
path?: string;
|
|
146
|
-
recursive?: boolean;
|
|
147
|
-
force?: boolean;
|
|
148
|
-
filter?: (file: string) => boolean;
|
|
149
|
-
}): number | undefined;
|
|
150
|
-
/**
|
|
151
|
-
* Copies single file to destination (auto-creates parent folders).
|
|
152
|
-
* @param {Object} options - Copy options.
|
|
153
|
-
* @param {string} options.path - Source file path.
|
|
154
|
-
* @param {string} options.dest - Destination path or folder.
|
|
155
|
-
* @param {boolean} [options.force=false] - Overwrite existing.
|
|
156
|
-
* @returns {boolean|undefined} Success status.
|
|
157
|
-
*/
|
|
158
|
-
export function copyFile(options: {
|
|
159
|
-
path: string;
|
|
160
|
-
dest: string;
|
|
161
|
-
force?: boolean;
|
|
162
|
-
}): boolean | undefined;
|
|
163
|
-
/**
|
|
164
|
-
* Moves multiple folders (copy + delete source).
|
|
165
|
-
* @param {Object} options - Move options (same as copyFoldersIn).
|
|
166
|
-
* @returns {number|undefined} Count of moved folders.
|
|
167
|
-
*/
|
|
168
|
-
export function moveFoldersIn(options: any): number | undefined;
|
|
169
|
-
/**
|
|
170
|
-
* Moves single folder (copy + delete source).
|
|
171
|
-
* @param {Object} options - Move options (same as copyFolder).
|
|
172
|
-
* @returns {boolean|undefined} Success status.
|
|
173
|
-
*/
|
|
174
|
-
export function moveFolder(options: any): boolean | undefined;
|
|
175
|
-
/**
|
|
176
|
-
* Moves multiple files (copy + delete source).
|
|
177
|
-
* @param {Object} options - Move options (same as copyFilesIn).
|
|
178
|
-
* @returns {number|undefined} Count of moved files.
|
|
179
|
-
*/
|
|
180
|
-
export function moveFilesIn(options: any): number | undefined;
|
|
181
|
-
/**
|
|
182
|
-
* Moves single file (copy + delete source).
|
|
183
|
-
* @param {Object} options - Move options (same as copyFile).
|
|
184
|
-
* @returns {boolean|undefined} Success status.
|
|
185
|
-
*/
|
|
186
|
-
export function moveFile(options: any): boolean | undefined;
|
|
187
|
-
/**
|
|
188
|
-
* Reads file content synchronously.
|
|
189
|
-
* @param {string} path - File path.
|
|
190
|
-
* @returns {string|undefined} File content or undefined.
|
|
191
|
-
*/
|
|
192
|
-
export function readFile(path: string): string | undefined;
|
|
193
|
-
/**
|
|
194
|
-
* Creates file system watcher with event filtering and pause/resume.
|
|
195
|
-
* @param {Object} [options] - Watcher options.
|
|
196
|
-
* @param {string} [options.path=process.cwd()] - Watch path.
|
|
197
|
-
* @param {boolean} [options.recursive=false] - Watch subdirectories.
|
|
198
|
-
* @param {(event: string, file: string) => boolean} [options.filter] - Event filter.
|
|
199
|
-
* @example
|
|
200
|
-
* const watcher = nodeComfort.watch({ path: "./src", recursive: true });
|
|
201
|
-
* watcher.on("change", (file) => console.log("Changed:", file));
|
|
202
|
-
* watcher.on("rename", (file) => console.log("Renamed:", file));
|
|
203
|
-
* watcher.on("all", (event, file) => console.log(event, file));
|
|
204
|
-
*/
|
|
205
|
-
export function watch(options?: {
|
|
206
|
-
path?: string;
|
|
207
|
-
recursive?: boolean;
|
|
208
|
-
filter?: (event: string, file: string) => boolean;
|
|
209
|
-
}): {
|
|
210
|
-
/**
|
|
211
|
-
* Adds event listener.
|
|
212
|
-
* @param {"change"|"rename"|"all"} event - Event type.
|
|
213
|
-
* @param {function} callback - Callback function.
|
|
214
|
-
*/
|
|
215
|
-
on(event: "change" | "rename" | "all", callback: Function): void;
|
|
216
|
-
stop(): void;
|
|
217
|
-
pause(): void;
|
|
218
|
-
resume(): void;
|
|
219
|
-
};
|
|
220
|
-
//# sourceMappingURL=FS.d.ts.map
|
package/types/core/FS.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../../core/FS.js"],"names":[],"mappings":"AAwME;;;;;;;;;;;;KAYE;AACF,4BALU,MAAM,YAEd;IAAyB,OAAO,GAAxB,MAAM;CACd,GAAU,MAAM,GAAC,SAAS,CAO3B;AACD;;;;;;;KAOE;AACF,kCALU,MAAM,GACJ,MAAM,CAajB;AAED;;;;;KAK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