@carlosdiazz/lottodiz-shared 1.2.3 → 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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../utils");
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);
11
+ };
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);
@@ -1 +1,3 @@
1
+ import "dayjs/locale/es.js";
2
+ import "dayjs/locale/en.js";
1
3
  export declare const validateDate: (date_verify: Date, arrs: string[]) => void;
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validateDate = void 0;
7
7
  const dayjs_1 = __importDefault(require("dayjs"));
8
8
  const utc_1 = __importDefault(require("dayjs/plugin/utc"));
9
+ require("dayjs/locale/es.js");
10
+ require("dayjs/locale/en.js");
9
11
  dayjs_1.default.extend(utc_1.default);
10
12
  const validateDate = (date_verify, arrs) => {
11
13
  if (arrs.length === 0)
@@ -14,10 +16,21 @@ const validateDate = (date_verify, arrs) => {
14
16
  if (!igual_dates)
15
17
  throw new Error("arrs is different");
16
18
  const date = arrs[0];
17
- //Aqui voy agregar los demas formatos
19
+ // Formatos en los dos idiomas
18
20
  const format_dates = [
19
- dayjs_1.default.utc(date_verify).format("DD-MM"), //Loterias Dominicanas
21
+ //Loterias Dominicanas
22
+ dayjs_1.default.utc(date_verify).format("DD-MM").toUpperCase(),
20
23
  ];
24
+ // Español
25
+ dayjs_1.default.locale("es");
26
+ format_dates.push(
27
+ //En Lote
28
+ dayjs_1.default.utc(date_verify).format("dddd D [de] MMMM, YYYY").toUpperCase());
29
+ // Ingles
30
+ dayjs_1.default.locale("en");
31
+ format_dates.push(
32
+ //Prueba Fecha Ingles
33
+ dayjs_1.default.utc(date_verify).format("dddd, MMMM D, YYYY").toUpperCase());
21
34
  const is_valid = format_dates.includes(date);
22
35
  if (!is_valid)
23
36
  throw new Error("This is not the date to look for");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlosdiazz/lottodiz-shared",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "Shared Dtos, models, constants and utils",
5
5
  "main": "dist/index.js",
6
6
  "private": false,