@ix-xs/node-comfort 1.1.3 → 1.1.31

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/package.json CHANGED
@@ -1,19 +1,16 @@
1
1
  {
2
2
  "name": "@ix-xs/node-comfort",
3
- "version": "1.1.3",
3
+ "version": "1.1.31",
4
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
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
6
+ "types": "types/index.d.ts",
9
7
  "keywords": [],
10
8
  "author": "ix-xs",
11
- "license": "MIT",
12
9
  "type": "commonjs",
13
- "engines": {
14
- "node": ">=20.12.0"
15
- },
16
- "repository": {
10
+ "engines": {
11
+ "node": ">=20.12.0"
12
+ },
13
+ "repository": {
17
14
  "type": "git",
18
15
  "url": "https://github.com/ix-xs/node-comfort.git"
19
16
  },
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "nodenext",
5
+ "allowJs": true,
6
+ "declaration": true,
7
+ "emitDeclarationOnly": true,
8
+ "outDir": "types",
9
+ "declarationMap": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "moduleResolution": "nodenext",
13
+ "esModuleInterop": true,
14
+ "resolveJsonModule": true
15
+ },
16
+ "include": ["**/*"],
17
+ "exclude": ["node_modules", "types"]
18
+ }
@@ -0,0 +1,120 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,145 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,243 @@
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
@@ -0,0 +1 @@
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,mCAJW,MAAM,UACN,OAAO,GACL,OAAO,GAAC,SAAS,CAoB7B;AAED;;;;;;GAMG;AACH,iCALW,MAAM,UACN,OAAO,SACP,MAAM,GAAC,MAAM,GAAC,IAAI,GAAC,SAAS,GAC1B,OAAO,GAAC,SAAS,CA+B7B;AAED;;;;;GAKG;AACH,uCAJW,MAAM,WACN,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,GACzB,MAAM,GAAC,SAAS,CAe5B;AAED;;;;GAIG;AACH,mCAHW,MAAM,GACJ,OAAO,GAAC,SAAS,CAY7B;AAED;;;;;;GAMG;AACH,qCALW,MAAM,cACN,OAAO,WACP,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GACvB,MAAM,GAAC,SAAS,CAe5B;AAED;;;;GAIG;AACH,iCAHW,MAAM,GACJ,OAAO,GAAC,SAAS,CA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;;;GAIG;AACH,+BAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAW5B;AAED;;;;;;;;;;;;GAYG;AACH,gCAVG;IAAyB,IAAI;IACH,SAAS;IACmC,MAAM,YAA5D,QAAQ,GAAC,QAAQ,QAAQ,MAAM,KAAK,OAAO;CAC3D,GAAU;IACR,EAAE,EAAE,CAAC,CAAC,SAAS,QAAQ,GAAC,QAAQ,GAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,SAAS,KAAK,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC;IAC5L,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,CAAC;CACnB,GAAC,SAAS,CAkGb"}
@@ -0,0 +1,35 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,391 @@
1
+ export = SQLite;
2
+ declare class SQLite {
3
+ /**
4
+ * Creates a new SQLite database connection.
5
+ *
6
+ * The database file and its parent folders are created if necessary.
7
+ * WAL journal mode and foreign key support are enabled automatically.
8
+ *
9
+ * @param {string} [path] - Path to the SQLite database file.
10
+ *
11
+ * @example
12
+ * const db = new SQLite();
13
+ *
14
+ * @example
15
+ * const db = new SQLite("data/my-app.sqlite");
16
+ */
17
+ constructor(path?: string);
18
+ /**
19
+ * Executes a raw SQL statement using `run()`.
20
+ *
21
+ * Use this for custom SQL that is not covered by the helper methods.
22
+ * This method is intended for statements such as:
23
+ * - `INSERT`
24
+ * - `UPDATE`
25
+ * - `DELETE`
26
+ * - `CREATE INDEX`
27
+ * - PRAGMA writes
28
+ *
29
+ * @param {string} sql - SQL statement.
30
+ * @param {any[]|any} [params=[]] - Parameters to bind.
31
+ * @returns {Promise<{ changes: number, lastInsertRowid: bigint|number } | { error: string }>}
32
+ */
33
+ exec(sql: string, params?: any[] | any): Promise<{
34
+ changes: number;
35
+ lastInsertRowid: bigint | number;
36
+ } | {
37
+ error: string;
38
+ }>;
39
+ /**
40
+ * Executes a raw SQL query and returns the first row.
41
+ *
42
+ * @param {string} sql - SQL query.
43
+ * @param {any[]|any} [params=[]] - Parameters to bind.
44
+ * @returns {Promise<object|undefined|{ error: string }>}
45
+ */
46
+ queryOne(sql: string, params?: any[] | any): Promise<object | undefined | {
47
+ error: string;
48
+ }>;
49
+ /**
50
+ * Executes a raw SQL query and returns all rows.
51
+ *
52
+ * @param {string} sql - SQL query.
53
+ * @param {any[]|any} [params=[]] - Parameters to bind.
54
+ * @returns {Promise<object[]|{ error: string }>}
55
+ */
56
+ queryAll(sql: string, params?: any[] | any): Promise<object[] | {
57
+ error: string;
58
+ }>;
59
+ /**
60
+ * Creates a table and stores its schema in memory.
61
+ *
62
+ * This method supports both the new `columns` property and the legacy
63
+ * `options` property for backward compatibility.
64
+ *
65
+ * @param {{
66
+ * name: string,
67
+ * columns?: Record<string, {
68
+ * type: "INTEGER"|"TEXT"|"REAL"|"BLOB"|"NUMERIC",
69
+ * primaryKey?: boolean,
70
+ * autoincrement?: boolean,
71
+ * notNull?: boolean,
72
+ * unique?: boolean,
73
+ * defaultValue?: any,
74
+ * values?: any[],
75
+ * references?: { table: string, column: string },
76
+ * onDelete?: string,
77
+ * onUpdate?: string
78
+ * }>,
79
+ * options?: Record<string, any>,
80
+ * constraints?: Array<
81
+ * | { type: "unique", columns: string[] }
82
+ * | { type: "primaryKey", columns: string[] }
83
+ * | { type: "check", expression: string }
84
+ * | {
85
+ * type: "foreignKey",
86
+ * columns: string[],
87
+ * references: { table: string, columns: string[] },
88
+ * onDelete?: string,
89
+ * onUpdate?: string
90
+ * }
91
+ * >,
92
+ * indexes?: Array<{
93
+ * name?: string,
94
+ * columns: string[],
95
+ * unique?: boolean
96
+ * }>
97
+ * }} table - Table definition.
98
+ * @returns {Promise<{ ok: true } | { error: string }>}
99
+ *
100
+ * @example
101
+ * await db.createTable({
102
+ * name: "Post",
103
+ * columns: {
104
+ * id: { type: "INTEGER", primaryKey: true, autoincrement: true },
105
+ * userId: {
106
+ * type: "INTEGER",
107
+ * notNull: true,
108
+ * references: { table: "User", column: "id" },
109
+ * onDelete: "CASCADE"
110
+ * },
111
+ * title: { type: "TEXT", notNull: true }
112
+ * },
113
+ * indexes: [{ columns: ["userId"] }]
114
+ * });
115
+ */
116
+ createTable(table: {
117
+ name: string;
118
+ columns?: Record<string, {
119
+ type: "INTEGER" | "TEXT" | "REAL" | "BLOB" | "NUMERIC";
120
+ primaryKey?: boolean;
121
+ autoincrement?: boolean;
122
+ notNull?: boolean;
123
+ unique?: boolean;
124
+ defaultValue?: any;
125
+ values?: any[];
126
+ references?: {
127
+ table: string;
128
+ column: string;
129
+ };
130
+ onDelete?: string;
131
+ onUpdate?: string;
132
+ }>;
133
+ options?: Record<string, any>;
134
+ constraints?: Array<{
135
+ type: "unique";
136
+ columns: string[];
137
+ } | {
138
+ type: "primaryKey";
139
+ columns: string[];
140
+ } | {
141
+ type: "check";
142
+ expression: string;
143
+ } | {
144
+ type: "foreignKey";
145
+ columns: string[];
146
+ references: {
147
+ table: string;
148
+ columns: string[];
149
+ };
150
+ onDelete?: string;
151
+ onUpdate?: string;
152
+ }>;
153
+ indexes?: Array<{
154
+ name?: string;
155
+ columns: string[];
156
+ unique?: boolean;
157
+ }>;
158
+ }): Promise<{
159
+ ok: true;
160
+ } | {
161
+ error: string;
162
+ }>;
163
+ /**
164
+ * Creates an index on an existing table.
165
+ *
166
+ * Composite indexes are supported by passing multiple columns.
167
+ *
168
+ * @param {string} tableName - Table name.
169
+ * @param {{
170
+ * name?: string,
171
+ * columns: string[],
172
+ * unique?: boolean
173
+ * }} index - Index definition.
174
+ * @returns {Promise<{ ok: true } | { error: string }>}
175
+ *
176
+ * @example
177
+ * await db.createIndex("UserAuthMethod", {
178
+ * columns: ["provider", "providerUserId"],
179
+ * unique: true
180
+ * });
181
+ */
182
+ createIndex(tableName: string, index: {
183
+ name?: string;
184
+ columns: string[];
185
+ unique?: boolean;
186
+ }): Promise<{
187
+ ok: true;
188
+ } | {
189
+ error: string;
190
+ }>;
191
+ /**
192
+ * Drops a table and removes its model definition.
193
+ *
194
+ * @param {string} tableName - Table name.
195
+ * @returns {Promise<{ ok: true } | { error: string }>}
196
+ */
197
+ deleteTable(tableName: string): Promise<{
198
+ ok: true;
199
+ } | {
200
+ error: string;
201
+ }>;
202
+ /**
203
+ * Deletes all rows from a table.
204
+ *
205
+ * @param {string} tableName - Table name.
206
+ * @returns {Promise<{ ok: true } | { error: string }>}
207
+ */
208
+ clearTable(tableName: string): Promise<{
209
+ ok: true;
210
+ } | {
211
+ error: string;
212
+ }>;
213
+ /**
214
+ * Returns a single row matching a plain-object WHERE clause.
215
+ *
216
+ * @param {string} tableName - Table name.
217
+ * @param {Record<string, any>} [where={}] - Conditions.
218
+ * @returns {Promise<object|undefined|{ error: string }>}
219
+ */
220
+ get(tableName: string, where?: Record<string, any>): Promise<object | undefined | {
221
+ error: string;
222
+ }>;
223
+ /**
224
+ * Returns multiple rows from a table.
225
+ *
226
+ * Supports:
227
+ * - exact-match filters via `where`
228
+ * - custom ordering
229
+ * - pagination via `limit` and `offset`
230
+ *
231
+ * @param {string} tableName - Table name.
232
+ * @param {Record<string, any>} [where={}] - Exact-match conditions.
233
+ * @param {{
234
+ * limit?: number,
235
+ * offset?: number,
236
+ * orderBy?: string,
237
+ * direction?: "ASC"|"DESC"
238
+ * }} [options={}] - Query options.
239
+ * @returns {Promise<object[] | { error: string }>}
240
+ *
241
+ * @example
242
+ * const posts = await db.getAll("Post", { userId: 1 }, {
243
+ * limit: 20,
244
+ * offset: 0,
245
+ * orderBy: "createdAt",
246
+ * direction: "DESC"
247
+ * });
248
+ */
249
+ getAll(tableName: string, where?: Record<string, any>, options?: {
250
+ limit?: number;
251
+ offset?: number;
252
+ orderBy?: string;
253
+ direction?: "ASC" | "DESC";
254
+ }): Promise<object[] | {
255
+ error: string;
256
+ }>;
257
+ /**
258
+ * Inserts a new row into a table.
259
+ *
260
+ * This method performs a plain `INSERT`.
261
+ * If a unique constraint is violated, SQLite will throw an error.
262
+ *
263
+ * @param {string} tableName - Table name.
264
+ * @param {Record<string, any>} data - Row to insert.
265
+ * @returns {Promise<{ ok: true, lastInsertRowid: bigint|number, changes: number } | { error: string }>}
266
+ */
267
+ insert(tableName: string, data: Record<string, any>): Promise<{
268
+ ok: true;
269
+ lastInsertRowid: bigint | number;
270
+ changes: number;
271
+ } | {
272
+ error: string;
273
+ }>;
274
+ /**
275
+ * Updates one or more rows matching a WHERE clause.
276
+ *
277
+ * This method performs a plain `UPDATE`.
278
+ *
279
+ * @param {string} tableName - Table name.
280
+ * @param {Record<string, any>} data - Fields to update.
281
+ * @param {Record<string, any>} where - Conditions used to select rows.
282
+ * @returns {Promise<{ ok: true, changes: number } | { error: string }>}
283
+ */
284
+ update(tableName: string, data: Record<string, any>, where: Record<string, any>): Promise<{
285
+ ok: true;
286
+ changes: number;
287
+ } | {
288
+ error: string;
289
+ }>;
290
+ /**
291
+ * Inserts or updates a row using SQLite `ON CONFLICT DO UPDATE`.
292
+ *
293
+ * This is safer than `INSERT OR REPLACE` because it does not delete
294
+ * and recreate the row.
295
+ *
296
+ * @param {string} tableName - Table name.
297
+ * @param {Record<string, any>} data - Row data.
298
+ * @param {string[]} conflict - Columns that define the conflict target.
299
+ * @returns {Promise<{ ok: true, changes: number, lastInsertRowid: bigint|number } | { error: string }>}
300
+ *
301
+ * @example
302
+ * await db.upsert("UserAuthMethod", {
303
+ * userId: 1,
304
+ * provider: "google",
305
+ * providerUserId: "123"
306
+ * }, ["provider", "providerUserId"]);
307
+ */
308
+ upsert(tableName: string, data: Record<string, any>, conflict?: string[]): Promise<{
309
+ ok: true;
310
+ changes: number;
311
+ lastInsertRowid: bigint | number;
312
+ } | {
313
+ error: string;
314
+ }>;
315
+ /**
316
+ * Backward-compatible helper that inserts or updates a row.
317
+ *
318
+ * Behavior:
319
+ * - If `where` is provided, the existing row is loaded and merged with `data`,
320
+ * then updated if found or inserted if not found.
321
+ * - If `where` is not provided but `data.id` exists, lookup is performed on `id`.
322
+ * - If no existing row is found, a new row is inserted.
323
+ *
324
+ * This method is intentionally simple, but for production-grade control,
325
+ * prefer using `insert()`, `update()`, or `upsert()`.
326
+ *
327
+ * @param {string} tableName - Table name.
328
+ * @param {Record<string, any>} data - Row data.
329
+ * @param {Record<string, any>|null} [where=null] - Lookup condition.
330
+ * @returns {Promise<{ ok: true } | { error: string }>}
331
+ */
332
+ set(tableName: string, data: Record<string, any>, where?: Record<string, any> | null): Promise<{
333
+ ok: true;
334
+ } | {
335
+ error: string;
336
+ }>;
337
+ /**
338
+ * Deletes rows matching a WHERE clause.
339
+ *
340
+ * @param {string} tableName - Table name.
341
+ * @param {Record<string, any>} where - Conditions.
342
+ * @returns {Promise<{ ok: true, changes: number } | { error: string }>}
343
+ */
344
+ delete(tableName: string, where: Record<string, any>): Promise<{
345
+ ok: true;
346
+ changes: number;
347
+ } | {
348
+ error: string;
349
+ }>;
350
+ /**
351
+ * Counts rows matching a WHERE clause.
352
+ *
353
+ * @param {string} tableName - Table name.
354
+ * @param {Record<string, any>} [where={}] - Conditions.
355
+ * @returns {Promise<number | { error: string }>}
356
+ */
357
+ count(tableName: string, where?: Record<string, any>): Promise<number | {
358
+ error: string;
359
+ }>;
360
+ /**
361
+ * Runs multiple operations inside a transaction.
362
+ *
363
+ * If the callback throws, the transaction is rolled back.
364
+ * If the callback completes successfully, the transaction is committed.
365
+ *
366
+ * The callback may be synchronous or asynchronous.
367
+ *
368
+ * @template T
369
+ * @param {() => T|Promise<T>} callback - Function to execute inside the transaction.
370
+ * @returns {Promise<T | { error: string }>}
371
+ *
372
+ * @example
373
+ * const result = await db.transaction(async () => {
374
+ * await db.insert("User", { email: "a@b.com", createdAt: Date.now() });
375
+ * await db.insert("Profile", { userId: 1, nickname: "John" });
376
+ * return { ok: true };
377
+ * });
378
+ */
379
+ transaction<T>(callback: () => T | Promise<T>): Promise<T | {
380
+ error: string;
381
+ }>;
382
+ /**
383
+ * Closes the underlying SQLite connection.
384
+ *
385
+ * @example
386
+ * db.close();
387
+ */
388
+ close(): void;
389
+ #private;
390
+ }
391
+ //# sourceMappingURL=SQLite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SQLite.d.ts","sourceRoot":"","sources":["../../src/SQLite.js"],"names":[],"mappings":";AA0DiB;IAef;;;;;;;;;;;;;OAaG;IACH,mBARW,MAAM,EAmBhB;IA8TD;;;;;;;;;;;;;;OAcG;IACH,UAJW,MAAM,WACN,GAAG,EAAE,GAAC,GAAG,GACP,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,GAAC,MAAM,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAQ5F;IAED;;;;;;OAMG;IACH,cAJW,MAAM,WACN,GAAG,EAAE,GAAC,GAAG,GACP,OAAO,CAAC,MAAM,GAAC,SAAS,GAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAUvD;IAED;;;;;;OAMG;IACH,cAJW,MAAM,WACN,GAAG,EAAE,GAAC,GAAG,GACP,OAAO,CAAC,MAAM,EAAE,GAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAS/C;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,mBAnDW;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;YACvB,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,CAAC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;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAwB1C;IAED;;;;;OAKG;IACH,cAIC;;CACF"}
@@ -0,0 +1,124 @@
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
@@ -0,0 +1 @@
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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