@carlosdiazz/lottodiz-shared 1.2.4 → 1.2.5

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.
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const main = () => {
5
- const date = new Date("2025-10-22");
6
- (0, utils_1.validateDate)(date, ["test"]);
7
- console.log(date);
4
+ const main = async () => {
5
+ //const date = new Date("2025-10-22");
6
+ //validateDate(date, ["test"]);
7
+ //console.log(date);
8
+ await (0, utils_1.exectFunction)(() => {
9
+ throw new Error("OO");
10
+ }, 5, 1);
8
11
  };
9
12
  main();
@@ -0,0 +1,3 @@
1
+ type AnyFunction = (...args: any[]) => any;
2
+ export declare const exectFunction: <T extends AnyFunction>(fn: () => ReturnType<T> | Promise<ReturnType<T>>, attempts?: number, sleepBySeconds?: number) => Promise<ReturnType<T> | void>;
3
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exectFunction = void 0;
4
+ const sleep_1 = require("./sleep");
5
+ const exectFunction = async (fn, attempts = 10, sleepBySeconds = 1) => {
6
+ for (let index = 0; index < attempts; index++) {
7
+ try {
8
+ return await fn();
9
+ }
10
+ catch (e) {
11
+ console.error(`Error exectFunction => ${e === null || e === void 0 ? void 0 : e.message} => attempt ${index + 1}/${attempts}`);
12
+ await (0, sleep_1.sleepSeconds)(sleepBySeconds);
13
+ }
14
+ }
15
+ };
16
+ exports.exectFunction = exectFunction;
@@ -6,3 +6,4 @@ export * from "./validate-arrays-equal";
6
6
  export * from "./validate-day";
7
7
  export * from "./validatePositionsResult";
8
8
  export * from "./deep-partial";
9
+ export * from "./exect-function";
@@ -22,3 +22,4 @@ __exportStar(require("./validate-arrays-equal"), exports);
22
22
  __exportStar(require("./validate-day"), exports);
23
23
  __exportStar(require("./validatePositionsResult"), exports);
24
24
  __exportStar(require("./deep-partial"), exports);
25
+ __exportStar(require("./exect-function"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlosdiazz/lottodiz-shared",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Shared Dtos, models, constants and utils",
5
5
  "main": "dist/index.js",
6
6
  "private": false,