@tmlmobilidade/utils 20260302.1453.8 → 20260305.1852.13

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A collection of utility functions and helpers for the TML Mobilidade Go monorepo, providing common functionality for batching operations, caching, HTTP requests, object manipulation, permissions, and more.
4
4
 
5
- ## Installation
5
+ ## Installation 1
6
6
 
7
7
  ```bash
8
8
  npm install @tmlmobilidade/utils
@@ -215,14 +215,14 @@ import { asyncSingletonProxy } from '@tmlmobilidade/utils';
215
215
 
216
216
  class Database {
217
217
  private static instance: Database | null = null;
218
-
218
+
219
219
  static async getInstance(): Promise<Database> {
220
220
  if (!this.instance) {
221
221
  this.instance = await this.initialize();
222
222
  }
223
223
  return this.instance;
224
224
  }
225
-
225
+
226
226
  async query(sql: string) {
227
227
  // ...
228
228
  }
@@ -239,5 +239,4 @@ AGPL-3.0-or-later
239
239
 
240
240
  ## Repository
241
241
 
242
- [GitHub](https://github.com/tmlmobilidade/go)
243
-
242
+ [GitHub](https://github.com/tmlmobilidade/go)
@@ -3,4 +3,4 @@
3
3
  * Errors are caught and logged per-invocation — they do not halt scheduling.
4
4
  * Each invocation is fire-and-forget after the first awaited call.
5
5
  */
6
- export declare function runOnInterval(fn: () => Promise<void>, intervalMs: number): () => void;
6
+ export declare function runOnInterval(fn: () => Promise<void>, intervalMs: number): Promise<void>;
@@ -3,18 +3,19 @@
3
3
  * Errors are caught and logged per-invocation — they do not halt scheduling.
4
4
  * Each invocation is fire-and-forget after the first awaited call.
5
5
  */
6
- export function runOnInterval(fn, intervalMs) {
7
- let intervalId = null;
8
- const execute = () => fn().catch((error) => {
9
- console.error('[runOnInterval] Unhandled error in scheduled function:', error);
10
- });
11
- // Await the first run before starting the interval so startup errors surface
12
- void execute().then(() => {
13
- intervalId = setInterval(() => void execute(), intervalMs);
14
- });
15
- // Return a cleanup function to cancel scheduling
16
- return () => {
17
- if (intervalId !== null)
18
- clearInterval(intervalId);
6
+ export async function runOnInterval(fn, intervalMs) {
7
+ //
8
+ const runner = async () => {
9
+ try {
10
+ await fn();
11
+ }
12
+ catch (error) {
13
+ console.error('Error in runOnInterval:', error);
14
+ }
15
+ finally {
16
+ setTimeout(runner, intervalMs);
17
+ }
19
18
  };
19
+ await runner();
20
+ //
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/utils",
3
- "version": "20260302.1453.8",
3
+ "version": "20260305.1852.13",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@tmlmobilidade/tsconfig": "*",
45
- "@types/node": "25.3.0",
45
+ "@types/node": "25.3.3",
46
46
  "resolve-tspaths": "0.8.23",
47
47
  "tsc-watch": "7.2.0",
48
48
  "typescript": "5.9.3"