@ix-xs/node-comfort 1.0.56 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,CAY7B;AAED;;;;;;;;;;GAUG;AACH,uCARG;IAAwB,IAAI,EAApB,MAAM;IACW,IAAI;IACH,SAAS;IACT,SAAS;IACT,KAAK;IACe,MAAM,aAAnC,MAAM,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,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,168 @@
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
@@ -0,0 +1 @@
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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MG;IACH,kBAJW,MAAM,SACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACjB,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAgBtE;IAED;;;;;;;;;;OAUG;IACH,iBAJW,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"}
@@ -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,MAA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-1,76 +0,0 @@
1
- const { types } = require("node:util");
2
-
3
- module.exports = {
4
- /**
5
- * @param {*} value
6
- */
7
- isArray(value) {
8
- return Array.isArray(value);
9
- },
10
- /**
11
- * @param {*} value
12
- */
13
- isNumber(value) {
14
- return typeof value === "number" && !Number.isNaN(value);
15
- },
16
- /**
17
- * @param {*} value
18
- */
19
- isFunction(value) {
20
- return typeof value === "function";
21
- },
22
- /**
23
- * @param {*} value
24
- */
25
- isObject(value) {
26
- return typeof value === "object" && value !== null;
27
- },
28
- /**
29
- * @param {*} value
30
- */
31
- isBoolean(value) {
32
- return typeof value === "boolean";
33
- },
34
- /**
35
- * @param {*} value
36
- */
37
- isString(value) {
38
- return typeof value === "string";
39
- },
40
- /**
41
- * @param {*} value
42
- */
43
- isUndefined(value) {
44
- return typeof value === "undefined";
45
- },
46
- /**
47
- * @param {*} value
48
- */
49
- isNull(value) {
50
- return value === null;
51
- },
52
- /**
53
- * @param {*} value
54
- */
55
- isDate(value) {
56
- return types.isDate(value);
57
- },
58
- /**
59
- * @param {*} value
60
- */
61
- isMap(value) {
62
- return types.isMap(value);
63
- },
64
- /**
65
- * @param {*} value
66
- */
67
- isSet(value) {
68
- return types.isSet(value);
69
- },
70
- /**
71
- * @param {*} value
72
- */
73
- isError(value) {
74
- return types.isNativeError(value);
75
- },
76
- };