amos-apptool 1.1.0 → 1.2.1
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/esm/index.js +1 -1
- package/esm/math/calendarUtils.js +22 -9
- package/esm/url/restfulUrl.js +36 -3
- package/index.d.ts +760 -288
- package/lib/index.js +11 -8
- package/lib/math/calendarUtils.js +18 -5
- package/lib/url/restfulUrl.js +35 -3
- package/package.json +1 -1
package/esm/index.js
CHANGED
|
@@ -23,8 +23,8 @@ const DateHelper = {
|
|
|
23
23
|
const n = new Date(Number(e), parseInt(t) - 1, Number(a));
|
|
24
24
|
let D = n.getDay();
|
|
25
25
|
const o = n.getDate();
|
|
26
|
-
let
|
|
27
|
-
return 0 !== r && (D = 0 === D ? 7 : D,
|
|
26
|
+
let y = 6 - D;
|
|
27
|
+
return 0 !== r && (D = 0 === D ? 7 : D, y = 7 - D), Math.ceil((o + y) / 7);
|
|
28
28
|
},
|
|
29
29
|
getYearWeek(e, t, a, r = 0) {
|
|
30
30
|
const n = new Date(Number(e), parseInt(t) - 1, Number(a)), D = new Date(Number(e), 0, 1), o = Math.round((n.valueOf() - D.valueOf()) / 864e5);
|
|
@@ -38,8 +38,8 @@ const DateHelper = {
|
|
|
38
38
|
return [ DateHelper.date2Str(new Date(t)), DateHelper.date2Str(new Date(a)) ];
|
|
39
39
|
}
|
|
40
40
|
o = 0 === o ? 7 : o;
|
|
41
|
-
const
|
|
42
|
-
return [ DateHelper.date2Str(new Date(
|
|
41
|
+
const y = 864e5, g = D - (o - 1) * y, s = D + (7 - o) * y;
|
|
42
|
+
return [ DateHelper.date2Str(new Date(g)), DateHelper.date2Str(new Date(s)) ];
|
|
43
43
|
},
|
|
44
44
|
formatResultDate(e) {
|
|
45
45
|
const t = [ ...e.split("-") ];
|
|
@@ -69,13 +69,13 @@ const DateHelper = {
|
|
|
69
69
|
n <= 0 && (n = 12, D += 1);
|
|
70
70
|
let o = DateHelper.getMonthPreDay(+t, +a);
|
|
71
71
|
o -= r, "prev" === e && o >= 7 && (o -= 7);
|
|
72
|
-
const
|
|
73
|
-
return Array.from(Array(
|
|
72
|
+
const y = DateHelper.getMonthDays(`${D}`, `${n}`);
|
|
73
|
+
return Array.from(Array(y), (t, a) => ({
|
|
74
74
|
day: a + 1,
|
|
75
75
|
type: e,
|
|
76
76
|
year: D,
|
|
77
77
|
month: n
|
|
78
|
-
})).slice(
|
|
78
|
+
})).slice(y - o);
|
|
79
79
|
}, convertDateToDay = e => e ? {
|
|
80
80
|
year: e.getFullYear(),
|
|
81
81
|
month: e.getMonth() + 1,
|
|
@@ -103,7 +103,19 @@ const DateHelper = {
|
|
|
103
103
|
}, getCurrentWeekDays = (e, t) => {
|
|
104
104
|
const a = new Date(e.year, e.month - 1, e.date), r = (a.getDay() + 7 - t) % 7;
|
|
105
105
|
return [ convertDateToDay(new Date(a.getTime() - 864e5 * r)), convertDateToDay(new Date(a.getTime() + 864e5 * (6 - r))) ];
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
function checkIsToday(e) {
|
|
109
|
+
if ("object" != typeof e) return !1;
|
|
110
|
+
const {type: t, year: a, month: r, date: n} = e || {};
|
|
111
|
+
if ("current" === t) {
|
|
112
|
+
const e = new Date, t = convertDateToDay(e);
|
|
113
|
+
return a === t.year && r === t.month && n === t.date;
|
|
114
|
+
}
|
|
115
|
+
return !1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const CalendarUtils = {
|
|
107
119
|
DateHelper: DateHelper,
|
|
108
120
|
getCurrMonthData: getCurrMonthData,
|
|
109
121
|
getDaysStatus: getDaysStatus,
|
|
@@ -112,7 +124,8 @@ const DateHelper = {
|
|
|
112
124
|
convertDayToDate: convertDayToDate,
|
|
113
125
|
getPrevMonthDays: getPrevMonthDays,
|
|
114
126
|
getCurrentMonthDays: getCurrentMonthDays,
|
|
115
|
-
getCurrentWeekDays: getCurrentWeekDays
|
|
127
|
+
getCurrentWeekDays: getCurrentWeekDays,
|
|
128
|
+
checkIsToday: checkIsToday
|
|
116
129
|
};
|
|
117
130
|
|
|
118
131
|
export { CalendarUtils };
|
package/esm/url/restfulUrl.js
CHANGED
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
import utils from "./../utils";
|
|
2
2
|
|
|
3
|
+
import parseText from "./../parseText";
|
|
4
|
+
|
|
5
|
+
import _trim from "./../_trim";
|
|
6
|
+
|
|
3
7
|
const _regex = /\{\s*([^\|\}]+?)\s*(?:\|([^\}]*))?\s*\}/g;
|
|
4
8
|
|
|
5
|
-
export
|
|
6
|
-
return
|
|
7
|
-
}
|
|
9
|
+
export function restfulUrl(t, r, e) {
|
|
10
|
+
return e || (e = _regex), t.replace ? t.replace(e, (t, e) => utils.isUndefined(r[e]) ? t : r[e]) : t;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const defaultRE = /\{((?:.|\n)+?)\}/g;
|
|
14
|
+
|
|
15
|
+
export function formatUrl(t, r = {}, e) {
|
|
16
|
+
return e || (e = defaultRE), parseText(t, r, e);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function changeParam(t, r) {
|
|
20
|
+
if (!t || utils.isEmpty(r)) return t;
|
|
21
|
+
let e = t;
|
|
22
|
+
return Object.keys(r).forEach(function(t) {
|
|
23
|
+
let i = r[t];
|
|
24
|
+
utils.isUndefined(i) ? i = "" : utils.isArray(i) || utils.isObject(i) && (i = JSON.stringify(i)),
|
|
25
|
+
e = function(t, r, e) {
|
|
26
|
+
const i = r + "=([^&]*)", n = r + "=" + e;
|
|
27
|
+
if (t.match(i)) {
|
|
28
|
+
const e = new RegExp(`(${r}=)([^&]*)`, "gi");
|
|
29
|
+
return t.replace(e, n);
|
|
30
|
+
}
|
|
31
|
+
return t.match("[?]") ? t + "&" + n : t + "?" + n;
|
|
32
|
+
}(e, t, i);
|
|
33
|
+
}), e;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const completePrefix = (t = "", r = "") => {
|
|
37
|
+
if (!t || "" === t) return r;
|
|
38
|
+
return t.endsWith("/") && (t = t.substring(0, t.length - 1)), t = _trim(t), r.startsWith("/") && (r = r.substring(1)),
|
|
39
|
+
[ t, r = (r = _trim(r)).replace(/\/\/+/g, "/") ].join("/");
|
|
40
|
+
};
|