@carlosdiazz/lottodiz-shared 1.1.6 → 1.1.7
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/dist/utils/create-interval-array.d.ts +5 -0
- package/dist/utils/create-interval-array.js +30 -0
- package/dist/utils/get-day-number-of-day.d.ts +1 -0
- package/dist/utils/get-day-number-of-day.js +12 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/validatePositionsResult.d.ts +2 -0
- package/dist/utils/validatePositionsResult.js +60 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIntervalArray = void 0;
|
|
4
|
+
const createIntervalArray = (time_start, time_end, interval) => {
|
|
5
|
+
if (interval === 0)
|
|
6
|
+
return [{ time_end, time_start }];
|
|
7
|
+
const result = [];
|
|
8
|
+
// Convertimos a minutos totales desde medianoche
|
|
9
|
+
const toMinutes = (time) => {
|
|
10
|
+
const [hours, minutes] = time.split(":").map(Number);
|
|
11
|
+
return hours * 60 + minutes;
|
|
12
|
+
};
|
|
13
|
+
const toTimeString = (totalMinutes) => {
|
|
14
|
+
const h = Math.floor(totalMinutes / 60);
|
|
15
|
+
const m = totalMinutes % 60;
|
|
16
|
+
return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}`;
|
|
17
|
+
};
|
|
18
|
+
let start = toMinutes(time_start);
|
|
19
|
+
const end = toMinutes(time_end);
|
|
20
|
+
while (start + interval <= end) {
|
|
21
|
+
const next = start + interval;
|
|
22
|
+
result.push({
|
|
23
|
+
time_start: toTimeString(start),
|
|
24
|
+
time_end: toTimeString(next),
|
|
25
|
+
});
|
|
26
|
+
start = next;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
exports.createIntervalArray = createIntervalArray;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDayNumberOfDay: (dateString: string) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDayNumberOfDay = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const getDayNumberOfDay = (dateString) => {
|
|
9
|
+
const id_day = (0, dayjs_1.default)(dateString).day();
|
|
10
|
+
return id_day;
|
|
11
|
+
};
|
|
12
|
+
exports.getDayNumberOfDay = getDayNumberOfDay;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from "./convert-to-number-array";
|
|
2
|
+
export * from "./create-interval-array";
|
|
3
|
+
export * from "./get-day-number-of-day";
|
|
2
4
|
export * from "./sleep";
|
|
3
5
|
export * from "./validate-arrays-equal";
|
|
4
6
|
export * from "./validate-day";
|
|
7
|
+
export * from "./validatePositionsResult";
|
package/dist/utils/index.js
CHANGED
|
@@ -15,6 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./convert-to-number-array"), exports);
|
|
18
|
+
__exportStar(require("./create-interval-array"), exports);
|
|
19
|
+
__exportStar(require("./get-day-number-of-day"), exports);
|
|
18
20
|
__exportStar(require("./sleep"), exports);
|
|
19
21
|
__exportStar(require("./validate-arrays-equal"), exports);
|
|
20
22
|
__exportStar(require("./validate-day"), exports);
|
|
23
|
+
__exportStar(require("./validatePositionsResult"), exports);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePositionsResult = void 0;
|
|
4
|
+
const validatePositionsResult = (template_result, createDrawResultDto) => {
|
|
5
|
+
const { numbers_win, text_win } = createDrawResultDto;
|
|
6
|
+
const { position_result } = template_result;
|
|
7
|
+
if (!position_result)
|
|
8
|
+
throw new Error("position_result is requerid");
|
|
9
|
+
if (position_result.length === 0) {
|
|
10
|
+
throw new Error("You have no positions created");
|
|
11
|
+
}
|
|
12
|
+
if (template_result.is_text) {
|
|
13
|
+
validateString(template_result, text_win);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
validateNumber(template_result, numbers_win);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.validatePositionsResult = validatePositionsResult;
|
|
20
|
+
const validateString = (template_result, arr_string) => {
|
|
21
|
+
const { position_result } = template_result;
|
|
22
|
+
if (!position_result)
|
|
23
|
+
throw new Error("position_result is requerid");
|
|
24
|
+
const valid = position_result.length;
|
|
25
|
+
if (!template_result.repetition) {
|
|
26
|
+
const set = new Set(arr_string);
|
|
27
|
+
if (set.size !== arr_string.length) {
|
|
28
|
+
throw Error(`You cannot have repeated elements`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (valid !== arr_string.length) {
|
|
32
|
+
throw Error(`You are sending a total of distinct elements Allowed: ${valid} You sent: ${arr_string.length}`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const validateNumber = (template_result, arr_number) => {
|
|
36
|
+
const { position_result } = template_result;
|
|
37
|
+
if (!position_result)
|
|
38
|
+
throw new Error("position_result is requerid");
|
|
39
|
+
const valid = position_result.length;
|
|
40
|
+
if (!template_result.repetition) {
|
|
41
|
+
const set = new Set(arr_number);
|
|
42
|
+
if (set.size !== arr_number.length) {
|
|
43
|
+
throw Error(`You cannot have repeated elements`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (position_result.length !== arr_number.length) {
|
|
47
|
+
throw Error(`You are sending a total of distinct elements Allowed: ${valid} You sent: ${arr_number.length}`);
|
|
48
|
+
}
|
|
49
|
+
for (let index = 0; index < position_result.length; index++) {
|
|
50
|
+
const numero = arr_number[index];
|
|
51
|
+
const rango_min = position_result[index].min_value;
|
|
52
|
+
const rango_max = position_result[index].max_value;
|
|
53
|
+
if (numero < rango_min) {
|
|
54
|
+
throw Error(`The number ${numero} cannot be less than ${rango_min} according to the rules of the game`);
|
|
55
|
+
}
|
|
56
|
+
if (numero > rango_max) {
|
|
57
|
+
throw Error(`The number ${numero} cannot be greater than ${rango_max} according to the rules of the game`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|