@ix-xs/node-comfort 1.1.0 → 1.1.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 +12 -0
- package/package.json +2 -3
- package/types/index.d.ts +0 -120
- package/types/index.d.ts.map +0 -1
- package/types/src/Checker.d.ts +0 -145
- package/types/src/Checker.d.ts.map +0 -1
- package/types/src/FS.d.ts +0 -243
- package/types/src/FS.d.ts.map +0 -1
- package/types/src/Logger.d.ts +0 -35
- package/types/src/Logger.d.ts.map +0 -1
- package/types/src/SQLite.d.ts +0 -168
- package/types/src/SQLite.d.ts.map +0 -1
- package/types/src/Utils.d.ts +0 -124
- package/types/src/Utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ix-xs/node-comfort
|
|
2
2
|
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/@ix-xs/node-comfort)
|
|
11
|
+
[](https://www.npmjs.com/package/@ix-xs/node-comfot)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
3
15
|
Small collection of Node.js utilities I use across projects: a logger, a file-system helper, a SQLite wrapper, a runtime type checker, and a few async/process helpers.
|
|
4
16
|
|
|
5
17
|
Everything is plain CommonJS with JSDoc, and ships with `.d.ts` so you get autocomplete in TypeScript and modern editors.
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ix-xs/node-comfort",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Small collection of Node.js utilities: colorful logger, filesystem helper, SQLite wrapper, runtime type checks and async/process helpers.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"types": "types/index.d.ts",
|
|
7
6
|
"scripts": {
|
|
8
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
8
|
},
|
package/types/index.d.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
declare const _exports: {
|
|
2
|
-
SQLite: {
|
|
3
|
-
new (path?: string): SQLite;
|
|
4
|
-
};
|
|
5
|
-
wait(ms: number): Promise<void>;
|
|
6
|
-
when(predicate: boolean | Promise<boolean> | (() => boolean | Promise<boolean>), payload?: any, options?: {
|
|
7
|
-
interval?: number | undefined;
|
|
8
|
-
timeout?: number | null | undefined;
|
|
9
|
-
max?: number | null | undefined;
|
|
10
|
-
}): {
|
|
11
|
-
start: () => any;
|
|
12
|
-
stop: () => any;
|
|
13
|
-
on: <E extends "error" | "trigger" | "timeout">(event: E, handler: E extends "error" ? (error: unknown) => void | Promise<void> : (payload: any) => void | Promise<void>) => any;
|
|
14
|
-
};
|
|
15
|
-
dontCrash(): {
|
|
16
|
-
on: <E extends "error" | "exit" | "sig" | "beforeExit">(event: E, handler?: (E extends "error" ? (error: Error | unknown) => void | Promise<void> : E extends "exit" ? (code: number) => void | Promise<void> : E extends "sig" ? (signal: "SIGINT" | "SIGTERM" | "SIGQUIT") => void | Promise<void> : (code: number) => void | Promise<void>)) => any;
|
|
17
|
-
};
|
|
18
|
-
JSONString(value: any): string;
|
|
19
|
-
JSONParse(value: string): any;
|
|
20
|
-
isArray(value: any): boolean;
|
|
21
|
-
isNumber(value: any): boolean;
|
|
22
|
-
isFunction(value: any): boolean;
|
|
23
|
-
isObject(value: any): boolean;
|
|
24
|
-
isBoolean(value: any): boolean;
|
|
25
|
-
isString(value: any): boolean;
|
|
26
|
-
isUndefined(value: any): boolean;
|
|
27
|
-
isNull(value: any): boolean;
|
|
28
|
-
isDate(value: any): boolean;
|
|
29
|
-
isMap(value: any): boolean;
|
|
30
|
-
isSet(value: any): boolean;
|
|
31
|
-
isError(value: any): boolean;
|
|
32
|
-
getEnv(value: string, envFilePath?: string): string | undefined;
|
|
33
|
-
createPath(path?: string): string;
|
|
34
|
-
getFoldersIn(path?: string, recursive?: boolean): string[] | undefined;
|
|
35
|
-
getFolder(path?: string): string | undefined;
|
|
36
|
-
getFilesIn(path?: string, recursive?: boolean): string[] | undefined;
|
|
37
|
-
getFile(path: string): string | undefined;
|
|
38
|
-
createFolder(path: string, force?: boolean): boolean | undefined;
|
|
39
|
-
createFile(path: string, force?: boolean, data?: string | object | null | undefined): boolean | undefined;
|
|
40
|
-
deleteFoldersIn(path?: string, filter?: (folder: string) => boolean): number | undefined;
|
|
41
|
-
deleteFolder(path: string): boolean | undefined;
|
|
42
|
-
deleteFilesIn(path?: string, recursive?: boolean, filter?: (file: string) => boolean): number | undefined;
|
|
43
|
-
deleteFile(path: string): boolean | undefined;
|
|
44
|
-
copyFoldersIn(options: {
|
|
45
|
-
dest: string;
|
|
46
|
-
path?: string | undefined;
|
|
47
|
-
recursive?: boolean | undefined;
|
|
48
|
-
withFiles?: boolean | undefined;
|
|
49
|
-
force?: boolean | undefined;
|
|
50
|
-
filter?: ((folder: string) => boolean) | undefined;
|
|
51
|
-
}): number | undefined;
|
|
52
|
-
copyFolder(options: {
|
|
53
|
-
dest: string;
|
|
54
|
-
path?: string | undefined;
|
|
55
|
-
recursive?: boolean | undefined;
|
|
56
|
-
withFiles?: boolean | undefined;
|
|
57
|
-
force?: boolean | undefined;
|
|
58
|
-
}): boolean | undefined;
|
|
59
|
-
copyFilesIn(options: {
|
|
60
|
-
dest: string;
|
|
61
|
-
path?: string | undefined;
|
|
62
|
-
recursive?: boolean | undefined;
|
|
63
|
-
force?: boolean | undefined;
|
|
64
|
-
filter?: ((file: string) => boolean) | undefined;
|
|
65
|
-
}): number | undefined;
|
|
66
|
-
copyFile(options: {
|
|
67
|
-
path: string;
|
|
68
|
-
dest: string;
|
|
69
|
-
force?: boolean | undefined;
|
|
70
|
-
}): boolean | undefined;
|
|
71
|
-
moveFoldersIn(options: {
|
|
72
|
-
dest: string;
|
|
73
|
-
path?: string | undefined;
|
|
74
|
-
recursive?: boolean | undefined;
|
|
75
|
-
withFiles?: boolean | undefined;
|
|
76
|
-
force?: boolean | undefined;
|
|
77
|
-
filter?: ((folder: string) => boolean) | undefined;
|
|
78
|
-
}): number | undefined;
|
|
79
|
-
moveFolder(options: {
|
|
80
|
-
path: string;
|
|
81
|
-
dest: string;
|
|
82
|
-
recursive?: boolean | undefined;
|
|
83
|
-
withFiles?: boolean | undefined;
|
|
84
|
-
force?: boolean | undefined;
|
|
85
|
-
}): boolean | undefined;
|
|
86
|
-
moveFilesIn(options: {
|
|
87
|
-
dest: string;
|
|
88
|
-
path?: string | undefined;
|
|
89
|
-
recursive?: boolean | undefined;
|
|
90
|
-
force?: boolean | undefined;
|
|
91
|
-
filter?: ((file: string) => boolean) | undefined;
|
|
92
|
-
}): number | undefined;
|
|
93
|
-
moveFile(options: {
|
|
94
|
-
path: string;
|
|
95
|
-
dest: string;
|
|
96
|
-
force?: boolean | undefined;
|
|
97
|
-
}): boolean | undefined;
|
|
98
|
-
readFile(path: string): string | undefined;
|
|
99
|
-
watch(options?: {
|
|
100
|
-
path?: string | undefined;
|
|
101
|
-
recursive?: boolean | undefined;
|
|
102
|
-
filter?: ((event: "rename" | "change", file: string) => boolean) | undefined;
|
|
103
|
-
}): {
|
|
104
|
-
on: <E extends "change" | "rename" | "all">(event: E, callback: E extends "all" ? (event: "change" | "rename", file: string) => void | Promise<void> : (file: string) => void | Promise<void>) => any;
|
|
105
|
-
stop: () => void;
|
|
106
|
-
pause: () => any;
|
|
107
|
-
resume: () => any;
|
|
108
|
-
} | undefined;
|
|
109
|
-
setTimestamp(value: boolean): Logger;
|
|
110
|
-
setDelimiter(options?: {
|
|
111
|
-
open?: string | undefined;
|
|
112
|
-
close?: string | undefined;
|
|
113
|
-
}): Logger;
|
|
114
|
-
log(content: any): Logger;
|
|
115
|
-
group(label: string): Logger;
|
|
116
|
-
groupEnd(): Logger;
|
|
117
|
-
};
|
|
118
|
-
export = _exports;
|
|
119
|
-
import SQLite = require("./src/SQLite");
|
|
120
|
-
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;iFAYi3N,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAAn0C,MAAM;;;;QAAuZ,MAAM;uBAAiX,MAAM;0BAAq/B,MAAM;gBAA0T,MAAM"}
|
package/types/src/Checker.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if a value is a real Array.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* nodeComfort.Checker.isArray([1, 2, 3]); // true
|
|
6
|
-
* nodeComfort.Checker.isArray("not array"); // false
|
|
7
|
-
*
|
|
8
|
-
* @param {*} value - Value to check.
|
|
9
|
-
* @returns {boolean} True if the value is an Array.
|
|
10
|
-
*/
|
|
11
|
-
export function isArray(value: any): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Checks if a value is a number (excluding NaN).
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* nodeComfort.Checker.isNumber(42); // true
|
|
17
|
-
* nodeComfort.Checker.isNumber(NaN); // false
|
|
18
|
-
* nodeComfort.Checker.isNumber("42"); // false
|
|
19
|
-
*
|
|
20
|
-
* @param {*} value - Value to check.
|
|
21
|
-
* @returns {boolean} True if the value is a finite number or Infinity/-Infinity.
|
|
22
|
-
*/
|
|
23
|
-
export function isNumber(value: any): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Checks if a value is a function.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* nodeComfort.Checker.isFunction(() => {}); // true
|
|
29
|
-
* nodeComfort.Checker.isFunction(class {}); // true
|
|
30
|
-
* nodeComfort.Checker.isFunction("fn"); // false
|
|
31
|
-
*
|
|
32
|
-
* @param {*} value - Value to check.
|
|
33
|
-
* @returns {boolean} True if the value is a function.
|
|
34
|
-
*/
|
|
35
|
-
export function isFunction(value: any): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Checks if a value is a non-null object.
|
|
38
|
-
*
|
|
39
|
-
* Note: Arrays, Maps, Sets, Dates, etc. are also considered objects here.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* nodeComfort.Checker.isObject({}); // true
|
|
43
|
-
* nodeComfort.Checker.isObject([]); // true
|
|
44
|
-
* nodeComfort.Checker.isObject(null); // false
|
|
45
|
-
* nodeComfort.Checker.isObject("str"); // false
|
|
46
|
-
*
|
|
47
|
-
* @param {*} value - Value to check.
|
|
48
|
-
* @returns {boolean} True if the value is a non-null object.
|
|
49
|
-
*/
|
|
50
|
-
export function isObject(value: any): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Checks if a value is a boolean.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* nodeComfort.Checker.isBoolean(true); // true
|
|
56
|
-
* nodeComfort.Checker.isBoolean(false); // true
|
|
57
|
-
* nodeComfort.Checker.isBoolean(0); // false
|
|
58
|
-
*
|
|
59
|
-
* @param {*} value - Value to check.
|
|
60
|
-
* @returns {boolean} True if the value is a boolean.
|
|
61
|
-
*/
|
|
62
|
-
export function isBoolean(value: any): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Checks if a value is a string.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* nodeComfort.Checker.isString("hello"); // true
|
|
68
|
-
* nodeComfort.Checker.isString(123); // false
|
|
69
|
-
*
|
|
70
|
-
* @param {*} value - Value to check.
|
|
71
|
-
* @returns {boolean} True if the value is a string.
|
|
72
|
-
*/
|
|
73
|
-
export function isString(value: any): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Checks if a value is exactly undefined.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* nodeComfort.Checker.isUndefined(undefined); // true
|
|
79
|
-
* nodeComfort.Checker.isUndefined(null); // false
|
|
80
|
-
*
|
|
81
|
-
* @param {*} value - Value to check.
|
|
82
|
-
* @returns {boolean} True if the value is undefined.
|
|
83
|
-
*/
|
|
84
|
-
export function isUndefined(value: any): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Checks if a value is exactly null.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* nodeComfort.Checker.isNull(null); // true
|
|
90
|
-
* nodeComfort.Checker.isNull(undefined); // false
|
|
91
|
-
*
|
|
92
|
-
* @param {*} value - Value to check.
|
|
93
|
-
* @returns {boolean} True if the value is null.
|
|
94
|
-
*/
|
|
95
|
-
export function isNull(value: any): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Checks if a value is a built-in Date instance.
|
|
98
|
-
*
|
|
99
|
-
* Uses `util.types.isDate` under the hood to handle cross-realm Dates.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* nodeComfort.Checker.isDate(new Date()); // true
|
|
103
|
-
* nodeComfort.Checker.isDate("2024-01-01"); // false
|
|
104
|
-
*
|
|
105
|
-
* @param {*} value - Value to check.
|
|
106
|
-
* @returns {boolean} True if the value is a Date instance.
|
|
107
|
-
*/
|
|
108
|
-
export function isDate(value: any): boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Checks if a value is a built-in Map instance.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* nodeComfort.Checker.isMap(new Map()); // true
|
|
114
|
-
* nodeComfort.Checker.isMap({}); // false
|
|
115
|
-
*
|
|
116
|
-
* @param {*} value - Value to check.
|
|
117
|
-
* @returns {boolean} True if the value is a Map.
|
|
118
|
-
*/
|
|
119
|
-
export function isMap(value: any): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Checks if a value is a built-in Set instance.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* nodeComfort.Checker.isSet(new Set()); // true
|
|
125
|
-
* nodeComfort.Checker.isSet([]); // false
|
|
126
|
-
*
|
|
127
|
-
* @param {*} value - Value to check.
|
|
128
|
-
* @returns {boolean} True if the value is a Set.
|
|
129
|
-
*/
|
|
130
|
-
export function isSet(value: any): boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Checks if a value is a native Error instance.
|
|
133
|
-
*
|
|
134
|
-
* Uses `util.types.isNativeError` to correctly handle errors from other realms.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* nodeComfort.Checker.isError(new Error("x")); // true
|
|
138
|
-
* nodeComfort.Checker.isError(new TypeError("x")); // true
|
|
139
|
-
* nodeComfort.Checker.isError({ message: "x" }); // false
|
|
140
|
-
*
|
|
141
|
-
* @param {*} value - Value to check.
|
|
142
|
-
* @returns {boolean} True if the value is a native Error.
|
|
143
|
-
*/
|
|
144
|
-
export function isError(value: any): boolean;
|
|
145
|
-
//# sourceMappingURL=Checker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Checker.d.ts","sourceRoot":"","sources":["../../src/Checker.js"],"names":[],"mappings":"AAQE;;;;;;;;;GASG;AACH,+BAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;GAUG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;GAUG;AACH,kCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;;;;GAaG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;GAUG;AACH,iCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,gCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,mCAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,8BAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;;GAWG;AACH,8BAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,6BAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;GASG;AACH,6BAHW,GAAC,GACC,OAAO,CAInB;AAED;;;;;;;;;;;;GAYG;AACH,+BAHW,GAAC,GACC,OAAO,CAInB"}
|
package/types/src/FS.d.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads an environment variable from process.env.
|
|
3
|
-
* @param {string} value - The environment variable name.
|
|
4
|
-
* @param {string} [envFilePath] - Reserved for future use.
|
|
5
|
-
* @returns {string|undefined} The environment value, or undefined if not set.
|
|
6
|
-
*/
|
|
7
|
-
export function getEnv(value: string, envFilePath?: string): string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Resolves a path even when it does not already exist.
|
|
10
|
-
* @param {string} [path=process.cwd()] - The path to resolve.
|
|
11
|
-
* @returns {string} The resolved path.
|
|
12
|
-
*/
|
|
13
|
-
export function createPath(path?: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Returns folders found inside a path.
|
|
16
|
-
* @param {string} [path=process.cwd()] - The base path to inspect.
|
|
17
|
-
* @param {boolean} [recursive=true] - Whether to scan recursively.
|
|
18
|
-
* @returns {string[]|undefined} Matching folders, or undefined if the path cannot be resolved.
|
|
19
|
-
*/
|
|
20
|
-
export function getFoldersIn(path?: string, recursive?: boolean): string[] | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the resolved folder path.
|
|
23
|
-
* @param {string} [path=process.cwd()] - The folder path to resolve.
|
|
24
|
-
* @returns {string|undefined} The resolved folder path, or undefined if not found.
|
|
25
|
-
*/
|
|
26
|
-
export function getFolder(path?: string): string | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Returns files found inside a path.
|
|
29
|
-
* @param {string} [path=process.cwd()] - The base path to inspect.
|
|
30
|
-
* @param {boolean} [recursive=true] - Whether to scan recursively.
|
|
31
|
-
* @returns {string[]|undefined} Matching files, or undefined if the path cannot be resolved.
|
|
32
|
-
*/
|
|
33
|
-
export function getFilesIn(path?: string, recursive?: boolean): string[] | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Returns the resolved file path.
|
|
36
|
-
* @param {string} path - The file path to resolve.
|
|
37
|
-
* @returns {string|undefined} The resolved file path, or undefined if not found.
|
|
38
|
-
*/
|
|
39
|
-
export function getFile(path: string): string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a folder.
|
|
42
|
-
* @param {string} path - The folder path to create.
|
|
43
|
-
* @param {boolean} [force=false] - Whether to recreate the folder if it already exists.
|
|
44
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if no path was provided.
|
|
45
|
-
*/
|
|
46
|
-
export function createFolder(path: string, force?: boolean): boolean | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Creates a file.
|
|
49
|
-
* @param {string} path - The file path to create.
|
|
50
|
-
* @param {boolean} [force=false] - Whether to recreate the file if it already exists.
|
|
51
|
-
* @param {string|object|null|undefined} [data] - File content to write.
|
|
52
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if no path was provided.
|
|
53
|
-
*/
|
|
54
|
-
export function createFile(path: string, force?: boolean, data?: string | object | null | undefined): boolean | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Deletes folders found inside a path.
|
|
57
|
-
* @param {string} [path=process.cwd()] - The base path to inspect.
|
|
58
|
-
* @param {(folder: string) => boolean} [filter=() => true] - Filter applied to each folder path.
|
|
59
|
-
* @returns {number|undefined} Number of deleted folders, or undefined if the path cannot be resolved.
|
|
60
|
-
*/
|
|
61
|
-
export function deleteFoldersIn(path?: string, filter?: (folder: string) => boolean): number | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Deletes a folder.
|
|
64
|
-
* @param {string} path - The folder path to delete.
|
|
65
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if the path is invalid.
|
|
66
|
-
*/
|
|
67
|
-
export function deleteFolder(path: string): boolean | undefined;
|
|
68
|
-
/**
|
|
69
|
-
* Deletes files found inside a path.
|
|
70
|
-
* @param {string} [path=process.cwd()] - The base path to inspect.
|
|
71
|
-
* @param {boolean} [recursive=false] - Whether to scan recursively.
|
|
72
|
-
* @param {(file: string) => boolean} [filter=() => true] - Filter applied to each file path.
|
|
73
|
-
* @returns {number|undefined} Number of deleted files, or undefined if the path cannot be resolved.
|
|
74
|
-
*/
|
|
75
|
-
export function deleteFilesIn(path?: string, recursive?: boolean, filter?: (file: string) => boolean): number | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Deletes a file.
|
|
78
|
-
* @param {string} path - The file path to delete.
|
|
79
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if the path is invalid.
|
|
80
|
-
*/
|
|
81
|
-
export function deleteFile(path: string): boolean | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* Copies folders from a source path into a destination folder.
|
|
84
|
-
* @param {Object} options - Copy options.
|
|
85
|
-
* @param {string} options.dest - Destination path.
|
|
86
|
-
* @param {string} [options.path] - Source path.
|
|
87
|
-
* @param {boolean} [options.recursive=true] - Whether to recurse into subfolders.
|
|
88
|
-
* @param {boolean} [options.withFiles=false] - Whether to copy files as well.
|
|
89
|
-
* @param {boolean} [options.force=false] - Whether to overwrite existing folders.
|
|
90
|
-
* @param {(folder: string) => boolean} [options.filter=() => true] - Filter applied to each folder.
|
|
91
|
-
* @returns {number|undefined} Number of copied folders, or undefined if invalid input.
|
|
92
|
-
*/
|
|
93
|
-
export function copyFoldersIn(options: {
|
|
94
|
-
dest: string;
|
|
95
|
-
path?: string | undefined;
|
|
96
|
-
recursive?: boolean | undefined;
|
|
97
|
-
withFiles?: boolean | undefined;
|
|
98
|
-
force?: boolean | undefined;
|
|
99
|
-
filter?: ((folder: string) => boolean) | undefined;
|
|
100
|
-
}): number | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* Copies a folder to a destination path.
|
|
103
|
-
* @param {Object} options - Copy options.
|
|
104
|
-
* @param {string} options.dest - Destination path.
|
|
105
|
-
* @param {string} [options.path] - Source path.
|
|
106
|
-
* @param {boolean} [options.recursive=false] - Whether to copy subfolders.
|
|
107
|
-
* @param {boolean} [options.withFiles=false] - Whether to copy files.
|
|
108
|
-
* @param {boolean} [options.force=false] - Whether to overwrite the destination.
|
|
109
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if invalid input.
|
|
110
|
-
*/
|
|
111
|
-
export function copyFolder(options: {
|
|
112
|
-
dest: string;
|
|
113
|
-
path?: string | undefined;
|
|
114
|
-
recursive?: boolean | undefined;
|
|
115
|
-
withFiles?: boolean | undefined;
|
|
116
|
-
force?: boolean | undefined;
|
|
117
|
-
}): boolean | undefined;
|
|
118
|
-
/**
|
|
119
|
-
* Copies files from a source path into a destination folder.
|
|
120
|
-
* @param {Object} options - Copy options.
|
|
121
|
-
* @param {string} options.dest - Destination path.
|
|
122
|
-
* @param {string} [options.path] - Source path.
|
|
123
|
-
* @param {boolean} [options.recursive=true] - Whether to recurse into subfolders.
|
|
124
|
-
* @param {boolean} [options.force=false] - Whether to overwrite existing files.
|
|
125
|
-
* @param {(file: string) => boolean} [options.filter=() => true] - Filter applied to each file.
|
|
126
|
-
* @returns {number|undefined} Number of copied files, or undefined if invalid input.
|
|
127
|
-
*/
|
|
128
|
-
export function copyFilesIn(options: {
|
|
129
|
-
dest: string;
|
|
130
|
-
path?: string | undefined;
|
|
131
|
-
recursive?: boolean | undefined;
|
|
132
|
-
force?: boolean | undefined;
|
|
133
|
-
filter?: ((file: string) => boolean) | undefined;
|
|
134
|
-
}): number | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Copies a file to a destination path.
|
|
137
|
-
* @param {Object} options - Copy options.
|
|
138
|
-
* @param {string} options.path - Source file path.
|
|
139
|
-
* @param {string} options.dest - Destination path.
|
|
140
|
-
* @param {boolean} [options.force=false] - Whether to overwrite the destination file.
|
|
141
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if invalid input.
|
|
142
|
-
*/
|
|
143
|
-
export function copyFile(options: {
|
|
144
|
-
path: string;
|
|
145
|
-
dest: string;
|
|
146
|
-
force?: boolean | undefined;
|
|
147
|
-
}): boolean | undefined;
|
|
148
|
-
/**
|
|
149
|
-
* Moves folders from a source path into a destination folder.
|
|
150
|
-
* @param {Object} options - Move options.
|
|
151
|
-
* @param {string} options.dest - Destination path.
|
|
152
|
-
* @param {string} [options.path] - Source path.
|
|
153
|
-
* @param {boolean} [options.recursive=true] - Whether to recurse into subfolders.
|
|
154
|
-
* @param {boolean} [options.withFiles=false] - Whether to move files as well.
|
|
155
|
-
* @param {boolean} [options.force=false] - Whether to overwrite existing folders.
|
|
156
|
-
* @param {(folder: string) => boolean} [options.filter=() => true] - Filter applied to each folder.
|
|
157
|
-
* @returns {number|undefined} Number of copied folders, or undefined if invalid input.
|
|
158
|
-
*/
|
|
159
|
-
export function moveFoldersIn(options: {
|
|
160
|
-
dest: string;
|
|
161
|
-
path?: string | undefined;
|
|
162
|
-
recursive?: boolean | undefined;
|
|
163
|
-
withFiles?: boolean | undefined;
|
|
164
|
-
force?: boolean | undefined;
|
|
165
|
-
filter?: ((folder: string) => boolean) | undefined;
|
|
166
|
-
}): number | undefined;
|
|
167
|
-
/**
|
|
168
|
-
* Moves a folder to a destination path.
|
|
169
|
-
* @param {Object} options - Move options.
|
|
170
|
-
* @param {string} options.path - Source folder path.
|
|
171
|
-
* @param {string} options.dest - Destination path.
|
|
172
|
-
* @param {boolean} [options.recursive=false] - Whether to move subfolders.
|
|
173
|
-
* @param {boolean} [options.withFiles=false] - Whether to move files.
|
|
174
|
-
* @param {boolean} [options.force=false] - Whether to overwrite the destination.
|
|
175
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if invalid input.
|
|
176
|
-
*/
|
|
177
|
-
export function moveFolder(options: {
|
|
178
|
-
path: string;
|
|
179
|
-
dest: string;
|
|
180
|
-
recursive?: boolean | undefined;
|
|
181
|
-
withFiles?: boolean | undefined;
|
|
182
|
-
force?: boolean | undefined;
|
|
183
|
-
}): boolean | undefined;
|
|
184
|
-
/**
|
|
185
|
-
* Moves files from a source path into a destination folder.
|
|
186
|
-
* @param {Object} options - Move options.
|
|
187
|
-
* @param {string} options.dest - Destination path.
|
|
188
|
-
* @param {string} [options.path] - Source path.
|
|
189
|
-
* @param {boolean} [options.recursive=true] - Whether to recurse into subfolders.
|
|
190
|
-
* @param {boolean} [options.force=false] - Whether to overwrite existing files.
|
|
191
|
-
* @param {(file: string) => boolean} [options.filter=() => true] - Filter applied to each file.
|
|
192
|
-
* @returns {number|undefined} Number of copied files, or undefined if invalid input.
|
|
193
|
-
*/
|
|
194
|
-
export function moveFilesIn(options: {
|
|
195
|
-
dest: string;
|
|
196
|
-
path?: string | undefined;
|
|
197
|
-
recursive?: boolean | undefined;
|
|
198
|
-
force?: boolean | undefined;
|
|
199
|
-
filter?: ((file: string) => boolean) | undefined;
|
|
200
|
-
}): number | undefined;
|
|
201
|
-
/**
|
|
202
|
-
* Moves a file to a destination path.
|
|
203
|
-
* @param {Object} options - Move options.
|
|
204
|
-
* @param {string} options.path - Source file path.
|
|
205
|
-
* @param {string} options.dest - Destination path.
|
|
206
|
-
* @param {boolean} [options.force=false] - Whether to overwrite the destination file.
|
|
207
|
-
* @returns {boolean|undefined} True on success, false on failure, undefined if invalid input.
|
|
208
|
-
*/
|
|
209
|
-
export function moveFile(options: {
|
|
210
|
-
path: string;
|
|
211
|
-
dest: string;
|
|
212
|
-
force?: boolean | undefined;
|
|
213
|
-
}): boolean | undefined;
|
|
214
|
-
/**
|
|
215
|
-
* Reads a file as UTF-8 text.
|
|
216
|
-
* @param {string} path - The file path to read.
|
|
217
|
-
* @returns {string|undefined} File content, or undefined if the file cannot be read.
|
|
218
|
-
*/
|
|
219
|
-
export function readFile(path: string): string | undefined;
|
|
220
|
-
/**
|
|
221
|
-
* Watches a path and exposes event listeners.
|
|
222
|
-
* @param {Object} [options] - Watch options.
|
|
223
|
-
* @param {string} [options.path=process.cwd()] - Path to watch.
|
|
224
|
-
* @param {boolean} [options.recursive=false] - Whether to watch recursively.
|
|
225
|
-
* @param {(event: "rename"|"change", file: string) => boolean} [options.filter] - Filter applied before dispatch.
|
|
226
|
-
* @returns {{
|
|
227
|
-
* on: <E extends "change"|"rename"|"all">(event: E, callback: E extends "all" ? (event: "change"|"rename", file: string) => void|Promise<void> : (file: string) => void|Promise<void>) => any,
|
|
228
|
-
* stop: () => void,
|
|
229
|
-
* pause: () => any,
|
|
230
|
-
* resume: () => any,
|
|
231
|
-
* }|undefined} Watch controller, or undefined if the path cannot be resolved.
|
|
232
|
-
*/
|
|
233
|
-
export function watch(options?: {
|
|
234
|
-
path?: string | undefined;
|
|
235
|
-
recursive?: boolean | undefined;
|
|
236
|
-
filter?: ((event: "rename" | "change", file: string) => boolean) | undefined;
|
|
237
|
-
}): {
|
|
238
|
-
on: <E extends "change" | "rename" | "all">(event: E, callback: E extends "all" ? (event: "change" | "rename", file: string) => void | Promise<void> : (file: string) => void | Promise<void>) => any;
|
|
239
|
-
stop: () => void;
|
|
240
|
-
pause: () => any;
|
|
241
|
-
resume: () => any;
|
|
242
|
-
} | undefined;
|
|
243
|
-
//# sourceMappingURL=FS.d.ts.map
|
package/types/src/FS.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../../src/FS.js"],"names":[],"mappings":"AAmKE;;;;;GAKG;AACH,8BAJW,MAAM,gBACN,MAAM,GACJ,MAAM,GAAC,SAAS,CAI5B;AAED;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAWlB;AAED;;;;;GAKG;AACH,oCAJW,MAAM,cACN,OAAO,GACL,MAAM,EAAE,GAAC,SAAS,CAK9B;AAED;;;;GAIG;AACH,iCAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAI5B;AAED;;;;;GAKG;AACH,kCAJW,MAAM,cACN,OAAO,GACL,MAAM,EAAE,GAAC,SAAS,CAK9B;AAED;;;;GAIG;AACH,8BAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAI5B;AAED;;;;;GAKG;AACH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,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enables or disables timestamp in logs
|
|
3
|
-
* @param {boolean} value - True to enable, false to disable
|
|
4
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
5
|
-
*/
|
|
6
|
-
export function setTimestamp(value: boolean): Logger;
|
|
7
|
-
/**
|
|
8
|
-
* Changes the delimiters used for text formatting
|
|
9
|
-
* @param {object} options - Delimiter options
|
|
10
|
-
* @param {string} [options.open] - New opening delimiter
|
|
11
|
-
* @param {string} [options.close] - New closing delimiter
|
|
12
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
13
|
-
*/
|
|
14
|
-
export function setDelimiter(options?: {
|
|
15
|
-
open?: string | undefined;
|
|
16
|
-
close?: string | undefined;
|
|
17
|
-
}): Logger;
|
|
18
|
-
/**
|
|
19
|
-
* Prints a message to the console with ANSI formatting
|
|
20
|
-
* @param {*} content - Content to print (string, object, or other)
|
|
21
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
22
|
-
*/
|
|
23
|
-
export function log(content: any): Logger;
|
|
24
|
-
/**
|
|
25
|
-
* Start a log group (displays a label and adds indentation)
|
|
26
|
-
* @param {string} label - The group name to display
|
|
27
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
28
|
-
*/
|
|
29
|
-
export function group(label: string): Logger;
|
|
30
|
-
/**
|
|
31
|
-
* End the current log group
|
|
32
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
33
|
-
*/
|
|
34
|
-
export function groupEnd(): Logger;
|
|
35
|
-
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Logger.js"],"names":[],"mappings":"AA+NE;;;;GAIG;AACH,oCAHW,OAAO,GACL,MAAM,CAKlB;AAED;;;;;;GAMG;AACH,uCAJG;IAAyB,IAAI;IACJ,KAAK;CAC9B,GAAU,MAAM,CAQlB;AAED;;;;GAIG;AACH,6BAHW,GAAC,GACC,MAAM,CAiClB;AAED;;;;GAIG;AACH,6BAHW,MAAM,GACJ,MAAM,CAOlB;AAED;;;GAGG;AACH,4BAFa,MAAM,CAKlB"}
|
package/types/src/SQLite.d.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
export = SQLite;
|
|
2
|
-
declare class SQLite {
|
|
3
|
-
/**
|
|
4
|
-
* Creates a new SQLite instance.
|
|
5
|
-
*
|
|
6
|
-
* By default, the database file is created at `./db.sqlite` relative
|
|
7
|
-
* to the current working directory. You can pass a custom path if needed.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Default path: "./db.sqlite"
|
|
11
|
-
* const db = new SQLite();
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Custom path in a subfolder:
|
|
15
|
-
* const db = new SQLite("data/myapp.sqlite");
|
|
16
|
-
*
|
|
17
|
-
* @param {string} [path] - Path to the SQLite database file.
|
|
18
|
-
*/
|
|
19
|
-
constructor(path?: string);
|
|
20
|
-
/**
|
|
21
|
-
* Creates (or ensures) a table exists for a given model definition.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* await db.createTable({
|
|
25
|
-
* name: "sessions",
|
|
26
|
-
* options: {
|
|
27
|
-
* id: { type: "TEXT", primaryKey: true },
|
|
28
|
-
* data: { type: "TEXT" },
|
|
29
|
-
* },
|
|
30
|
-
* });
|
|
31
|
-
*
|
|
32
|
-
* @param {{ name: string, options: Record<string, {
|
|
33
|
-
* type: "INTEGER"|"TEXT"|"REAL"|"BLOB"|"NUMERIC",
|
|
34
|
-
* primaryKey?: boolean,
|
|
35
|
-
* autoincrement?: boolean,
|
|
36
|
-
* notNull?: boolean,
|
|
37
|
-
* unique?: boolean,
|
|
38
|
-
* defaultValue?: any,
|
|
39
|
-
* values?: any[]
|
|
40
|
-
* }> }} table
|
|
41
|
-
* @returns {Promise<{ ok: true } | { error: string }>}
|
|
42
|
-
*/
|
|
43
|
-
createTable(table: {
|
|
44
|
-
name: string;
|
|
45
|
-
options: Record<string, {
|
|
46
|
-
type: "INTEGER" | "TEXT" | "REAL" | "BLOB" | "NUMERIC";
|
|
47
|
-
primaryKey?: boolean;
|
|
48
|
-
autoincrement?: boolean;
|
|
49
|
-
notNull?: boolean;
|
|
50
|
-
unique?: boolean;
|
|
51
|
-
defaultValue?: any;
|
|
52
|
-
values?: any[];
|
|
53
|
-
}>;
|
|
54
|
-
}): Promise<{
|
|
55
|
-
ok: true;
|
|
56
|
-
} | {
|
|
57
|
-
error: string;
|
|
58
|
-
}>;
|
|
59
|
-
/**
|
|
60
|
-
* Drops a table and removes its model definition.
|
|
61
|
-
*
|
|
62
|
-
* @param {string} tableName
|
|
63
|
-
* @returns {Promise<{ ok: true } | { error: string }>}
|
|
64
|
-
*/
|
|
65
|
-
deleteTable(tableName: string): Promise<{
|
|
66
|
-
ok: true;
|
|
67
|
-
} | {
|
|
68
|
-
error: string;
|
|
69
|
-
}>;
|
|
70
|
-
/**
|
|
71
|
-
* Deletes all rows from a table.
|
|
72
|
-
*
|
|
73
|
-
* @param {string} tableName
|
|
74
|
-
* @returns {Promise<{ ok: true } | { error: string }>}
|
|
75
|
-
*/
|
|
76
|
-
clearTable(tableName: string): Promise<{
|
|
77
|
-
ok: true;
|
|
78
|
-
} | {
|
|
79
|
-
error: string;
|
|
80
|
-
}>;
|
|
81
|
-
/**
|
|
82
|
-
* Gets a single row matching a WHERE clause.
|
|
83
|
-
*
|
|
84
|
-
* Returns:
|
|
85
|
-
* - `undefined` if no row matches,
|
|
86
|
-
* - the row object if found,
|
|
87
|
-
* - `{ error }` if a database error occurred.
|
|
88
|
-
*
|
|
89
|
-
* @param {string} tableName
|
|
90
|
-
* @param {Record<string, any>} where
|
|
91
|
-
* @returns {Promise<object|undefined|{ error: string }>}
|
|
92
|
-
*/
|
|
93
|
-
get(tableName: string, where: Record<string, any>): Promise<object | undefined | {
|
|
94
|
-
error: string;
|
|
95
|
-
}>;
|
|
96
|
-
/**
|
|
97
|
-
* Gets multiple rows matching a WHERE clause.
|
|
98
|
-
*
|
|
99
|
-
* Returns:
|
|
100
|
-
* - an empty array if the table is not defined,
|
|
101
|
-
* - an array of row objects,
|
|
102
|
-
* - `{ error }` if a database error occurred.
|
|
103
|
-
*
|
|
104
|
-
* @param {string} tableName
|
|
105
|
-
* @param {Record<string, any>} [where={}]
|
|
106
|
-
* @param {number} [limit=50]
|
|
107
|
-
* @param {number} [offset=0]
|
|
108
|
-
* @returns {Promise<object[] | { error: string }>}
|
|
109
|
-
*/
|
|
110
|
-
getAll(tableName: string, where?: Record<string, any>, limit?: number, offset?: number): Promise<object[] | {
|
|
111
|
-
error: string;
|
|
112
|
-
}>;
|
|
113
|
-
/**
|
|
114
|
-
* Inserts or replaces a row in a table.
|
|
115
|
-
*
|
|
116
|
-
* If `where` is provided (or `data.id` exists), it will first load the existing row and
|
|
117
|
-
* merge it with `data`, then perform an `INSERT OR REPLACE`. This lets you do partial updates.
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* await db.set("users", { id: 1, name: "Jane" });
|
|
121
|
-
*
|
|
122
|
-
* @param {string} tableName
|
|
123
|
-
* @param {Record<string, any>} data
|
|
124
|
-
* @param {Record<string, any>|null} [where=null]
|
|
125
|
-
* @returns {Promise<{ ok: true } | { error: string }>}
|
|
126
|
-
*/
|
|
127
|
-
set(tableName: string, data: Record<string, any>, where?: Record<string, any> | null): Promise<{
|
|
128
|
-
ok: true;
|
|
129
|
-
} | {
|
|
130
|
-
error: string;
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Deletes rows matching a WHERE clause.
|
|
134
|
-
*
|
|
135
|
-
* @param {string} tableName
|
|
136
|
-
* @param {Record<string, any>} where
|
|
137
|
-
* @returns {Promise<{ ok: true, changes: number } | { error: string }>}
|
|
138
|
-
*/
|
|
139
|
-
delete(tableName: string, where: Record<string, any>): Promise<{
|
|
140
|
-
ok: true;
|
|
141
|
-
changes: number;
|
|
142
|
-
} | {
|
|
143
|
-
error: string;
|
|
144
|
-
}>;
|
|
145
|
-
/**
|
|
146
|
-
* Counts rows matching a WHERE clause.
|
|
147
|
-
*
|
|
148
|
-
* Returns:
|
|
149
|
-
* - the numeric count,
|
|
150
|
-
* - or `{ error }` if a database error occurred.
|
|
151
|
-
*
|
|
152
|
-
* @param {string} tableName
|
|
153
|
-
* @param {Record<string, any>} [where={}]
|
|
154
|
-
* @returns {Promise<number | { error: string }>}
|
|
155
|
-
*/
|
|
156
|
-
count(tableName: string, where?: Record<string, any>): Promise<number | {
|
|
157
|
-
error: string;
|
|
158
|
-
}>;
|
|
159
|
-
/**
|
|
160
|
-
* Closes the underlying SQLite connection (if the runtime supports it).
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* db.close();
|
|
164
|
-
*/
|
|
165
|
-
close(): void;
|
|
166
|
-
#private;
|
|
167
|
-
}
|
|
168
|
-
//# sourceMappingURL=SQLite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SQLite.d.ts","sourceRoot":"","sources":["../../src/SQLite.js"],"names":[],"mappings":";AA4CiB;IAMf;;;;;;;;;;;;;;;OAeG;IACH,mBAFW,MAAM,EAahB;IAwID;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,mBAXW;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;YAC9C,IAAI,EAAE,SAAS,GAAC,MAAM,GAAC,MAAM,GAAC,MAAM,GAAC,SAAS,CAAC;YAC/C,UAAU,CAAC,EAAE,OAAO,CAAC;YACrB,aAAa,CAAC,EAAE,OAAO,CAAC;YACxB,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,MAAM,CAAC,EAAE,OAAO,CAAC;YACjB,YAAY,CAAC,EAAE,GAAG,CAAC;YACnB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;SACf,CAAC,CAAA;KAAE,GACM,OAAO,CAA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BAJW,MAAM,UACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACjB,OAAO,CAAC,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAgB/C;IAED;;;;;OAKG;IACH,cAIC;;CACF"}
|
package/types/src/Utils.d.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Waits for a given number of milliseconds.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* await nodeComfort.wait(500); // waits 500 ms
|
|
6
|
-
*
|
|
7
|
-
* @param {number} ms - Delay in milliseconds.
|
|
8
|
-
* @returns {Promise<void>} A promise that resolves after the delay.
|
|
9
|
-
*/
|
|
10
|
-
export function wait(ms: number): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Polls a predicate at a given interval and emits events when it matches or times out.
|
|
13
|
-
*
|
|
14
|
-
* The predicate is evaluated every `options.interval` milliseconds (default: 50 ms).
|
|
15
|
-
* Be careful with the default interval: 50 ms is very frequent polling and can be
|
|
16
|
-
* unnecessarily CPU‑intensive if your predicate or trigger handlers are heavy.
|
|
17
|
-
* When `options.max` is `null`, the predicate can match indefinitely (infinite triggers),
|
|
18
|
-
* so you should choose an interval that makes sense for your use‑case.
|
|
19
|
-
*
|
|
20
|
-
* A `when(...)` task is one‑shot: once it has been stopped (manually or via `max`/`timeout`),
|
|
21
|
-
* calling `.start()` again on the same task will not restart it.
|
|
22
|
-
*
|
|
23
|
-
* @param {boolean|Promise<boolean>|(() => boolean|Promise<boolean>)} predicate
|
|
24
|
-
* Condition to evaluate at each tick, or a function returning it.
|
|
25
|
-
* @param {*} [payload={}]
|
|
26
|
-
* Value passed to listeners when events are emitted (e.g. an object or message).
|
|
27
|
-
* @param {object} [options]
|
|
28
|
-
* @param {number} [options.interval=50]
|
|
29
|
-
* Polling interval in milliseconds. Increase this value if your predicate is
|
|
30
|
-
* expensive or you expect many triggers without a `max` limit.
|
|
31
|
-
* @param {number|null} [options.timeout=null]
|
|
32
|
-
* Maximum time in milliseconds before emitting a "timeout" event and stopping.
|
|
33
|
-
* If `null`, no timeout is applied.
|
|
34
|
-
* @param {number|null} [options.max=null]
|
|
35
|
-
* Maximum number of successful predicate evaluations ("trigger" events) before
|
|
36
|
-
* automatically stopping. If `null`, triggers are infinite until `stop()` is called.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* // Basic usage: infinite triggers every 50 ms (default interval) – use with caution.
|
|
40
|
-
* const task = nodeComfort.when(() => true, { message: "Ok" });
|
|
41
|
-
*
|
|
42
|
-
* task
|
|
43
|
-
* .on("trigger", (payload) => {
|
|
44
|
-
* console.log(payload.message);
|
|
45
|
-
* // task.stop(); // stop when you’re done
|
|
46
|
-
* })
|
|
47
|
-
* .start();
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* // Safer usage: limit triggers and/or lower polling frequency.
|
|
51
|
-
* nodeComfort.when(() => true, { message: "Ok" }, { max: 1, interval: 500 })
|
|
52
|
-
* .on("trigger", (payload) => {
|
|
53
|
-
* console.log(payload.message);
|
|
54
|
-
* })
|
|
55
|
-
* .on("timeout", (payload) => {
|
|
56
|
-
* console.log("Timed out", payload);
|
|
57
|
-
* })
|
|
58
|
-
* .start();
|
|
59
|
-
*
|
|
60
|
-
* @returns {{
|
|
61
|
-
* start: () => any,
|
|
62
|
-
* stop: () => any,
|
|
63
|
-
* on: <E extends "error"|"trigger"|"timeout">(event: E, handler: E extends "error"
|
|
64
|
-
* ? (error: unknown) => void|Promise<void>
|
|
65
|
-
* : (payload: any) => void|Promise<void>) => any
|
|
66
|
-
* }} A small task controller with `start`, `stop` and `on`.
|
|
67
|
-
*/
|
|
68
|
-
export function when(predicate: boolean | Promise<boolean> | (() => boolean | Promise<boolean>), payload?: any, options?: {
|
|
69
|
-
interval?: number | undefined;
|
|
70
|
-
timeout?: number | null | undefined;
|
|
71
|
-
max?: number | null | undefined;
|
|
72
|
-
}): {
|
|
73
|
-
start: () => any;
|
|
74
|
-
stop: () => any;
|
|
75
|
-
on: <E extends "error" | "trigger" | "timeout">(event: E, handler: E extends "error" ? (error: unknown) => void | Promise<void> : (payload: any) => void | Promise<void>) => any;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Installs process-level safety nets for errors, exits and signals.
|
|
79
|
-
*
|
|
80
|
-
* By default, it:
|
|
81
|
-
* - logs uncaught exceptions and unhandled rejections,
|
|
82
|
-
* - logs process exit codes,
|
|
83
|
-
* - logs SIGINT/SIGTERM/SIGQUIT and exits with code 0.
|
|
84
|
-
*
|
|
85
|
-
* You can override each handler with `.on(event, handler)`.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* // Use defaults:
|
|
89
|
-
* nodeComfort.dontCrash();
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* // Custom error handler:
|
|
93
|
-
* nodeComfort.dontCrash().on("error", (err) => {
|
|
94
|
-
* console.error("Global error:", err);
|
|
95
|
-
* process.exit(1);
|
|
96
|
-
* });
|
|
97
|
-
*
|
|
98
|
-
* @returns {{
|
|
99
|
-
* on: <E extends "error"|"exit"|"sig"|"beforeExit">(event: E, handler?: (
|
|
100
|
-
* E extends "error" ? (error: Error|unknown) => void|Promise<void> :
|
|
101
|
-
* E extends "exit" ? (code: number) => void|Promise<void> :
|
|
102
|
-
* E extends "sig" ? (signal: "SIGINT"|"SIGTERM"|"SIGQUIT") => void|Promise<void> :
|
|
103
|
-
* (code: number) => void|Promise<void>
|
|
104
|
-
* )) => any
|
|
105
|
-
* }} A small controller to configure global handlers.
|
|
106
|
-
*/
|
|
107
|
-
export function dontCrash(): {
|
|
108
|
-
on: <E extends "error" | "exit" | "sig" | "beforeExit">(event: E, handler?: (E extends "error" ? (error: Error | unknown) => void | Promise<void> : E extends "exit" ? (code: number) => void | Promise<void> : E extends "sig" ? (signal: "SIGINT" | "SIGTERM" | "SIGQUIT") => void | Promise<void> : (code: number) => void | Promise<void>)) => any;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Safely stringifies a value to pretty-printed JSON (4 spaces indent).
|
|
112
|
-
*
|
|
113
|
-
* @param {*} value - Value to stringify.
|
|
114
|
-
* @returns {string} JSON string representation.
|
|
115
|
-
*/
|
|
116
|
-
export function JSONString(value: any): string;
|
|
117
|
-
/**
|
|
118
|
-
* Parses a JSON string.
|
|
119
|
-
*
|
|
120
|
-
* @param {string} value - JSON string to parse.
|
|
121
|
-
* @returns {*} Parsed value.
|
|
122
|
-
*/
|
|
123
|
-
export function JSONParse(value: string): any;
|
|
124
|
-
//# sourceMappingURL=Utils.d.ts.map
|
package/types/src/Utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/Utils.js"],"names":[],"mappings":"AAME;;;;;;;;GAQG;AACH,yBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAIzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,gCA7CW,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,CAAC,MAAM,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,CAAC,YAEzD,GAAC,YAGT;IAAyB,QAAQ;IAGH,OAAO;IAGP,GAAG;CAIjC,GAsBU;IACR,KAAK,EAAE,MAAM,GAAG,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,CAAC;IAChB,EAAE,EAAE,CAAC,CAAC,SAAS,OAAO,GAAC,SAAS,GAAC,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,OAAO,GAC1E,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC,GACtC,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAA;CACnD,CAsIH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