@shower/core 3.3.0 → 3.4.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.
@@ -1,28 +0,0 @@
1
- const units = ['s', 'm', 'h'];
2
- const hasUnits = (timing) => {
3
- return units.some((unit) => timing.includes(unit));
4
- };
5
-
6
- const parseUnits = (timing) => {
7
- return units.map((unit) => timing.match(`(\\S+)${unit}`)).map((match) => match && match[1]);
8
- };
9
-
10
- const parseColons = (timing) => {
11
- return `::${timing}`.split(':').reverse();
12
- };
13
-
14
- const SEC_IN_MIN = 60;
15
- const SEC_IN_HOUR = SEC_IN_MIN * 60;
16
-
17
- export default (timing) => {
18
- if (!timing) return 0;
19
-
20
- const parsed = hasUnits(timing) ? parseUnits(timing) : parseColons(timing);
21
-
22
- let [sec, min, hour] = parsed.map(Number);
23
-
24
- sec += min * SEC_IN_MIN;
25
- sec += hour * SEC_IN_HOUR;
26
-
27
- return Math.max(sec * 1000, 0);
28
- };