@haluo/util 0.0.11 → 0.0.12
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.
|
@@ -32,18 +32,21 @@ var CookieClass = /** @class */ (function () {
|
|
|
32
32
|
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
|
|
33
33
|
var d = new Date();
|
|
34
34
|
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
35
|
-
var expires = "expires="
|
|
36
|
-
document.cookie = name
|
|
35
|
+
var expires = "expires=".concat(d.toUTCString());
|
|
36
|
+
document.cookie = "".concat(name, "=").concat(value, ";").concat(expires, ";path=").concat(path, ";domain=").concat(domain, ";");
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* 清除Cookie
|
|
40
40
|
* @param {String} name
|
|
41
41
|
*/
|
|
42
|
-
CookieClass.prototype.clearCookie = function (
|
|
42
|
+
CookieClass.prototype.clearCookie = function (_a) {
|
|
43
|
+
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.path, path = _c === void 0 ? '/' : _c, _d = _a.domain, domain = _d === void 0 ? '.jddmoto.com' : _d;
|
|
43
44
|
this.setCookie({
|
|
44
45
|
name: name,
|
|
45
46
|
value: '',
|
|
46
47
|
exdays: -1,
|
|
48
|
+
path: path,
|
|
49
|
+
domain: domain
|
|
47
50
|
});
|
|
48
51
|
};
|
|
49
52
|
return CookieClass;
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
function replacementDate(data, fmt) {
|
|
15
15
|
for (var k in data) {
|
|
16
16
|
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
17
|
-
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00"
|
|
17
|
+
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00".concat(data[k])).substr(('' + data[k]).length)));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
return fmt;
|
|
@@ -70,7 +70,7 @@ var DateClass = /** @class */ (function () {
|
|
|
70
70
|
};
|
|
71
71
|
fmt = replacementYear(timeData, fmt);
|
|
72
72
|
if (/(E+)/.test(fmt)) {
|
|
73
|
-
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[timeData.getDay()
|
|
73
|
+
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week["".concat(timeData.getDay(), " ")]);
|
|
74
74
|
}
|
|
75
75
|
return replacementDate(o, fmt);
|
|
76
76
|
};
|
|
@@ -105,10 +105,10 @@ var DateClass = /** @class */ (function () {
|
|
|
105
105
|
if (ts <= 0)
|
|
106
106
|
return false;
|
|
107
107
|
return {
|
|
108
|
-
dd: (dd < 10 ? "0"
|
|
109
|
-
hh: (hh < 10 ? "0"
|
|
110
|
-
mm: (mm < 10 ? "0"
|
|
111
|
-
ss: (ss < 10 ? "0"
|
|
108
|
+
dd: (dd < 10 ? "0".concat(dd) : dd),
|
|
109
|
+
hh: (hh < 10 ? "0".concat(hh) : hh),
|
|
110
|
+
mm: (mm < 10 ? "0".concat(mm) : mm),
|
|
111
|
+
ss: (ss < 10 ? "0".concat(ss) : ss)
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
@@ -121,19 +121,19 @@ var DateClass = /** @class */ (function () {
|
|
|
121
121
|
var time = currentTime - startTime;
|
|
122
122
|
var year = Math.floor(time / (1000 * 60 * 60 * 24) / 30 / 12);
|
|
123
123
|
if (year)
|
|
124
|
-
return year
|
|
124
|
+
return "".concat(year, "\u5E74\u524D");
|
|
125
125
|
var month = Math.floor(time / (1000 * 60 * 60 * 24) / 30);
|
|
126
126
|
if (month)
|
|
127
|
-
return month
|
|
127
|
+
return "".concat(month, "\u4E2A\u6708\u524D");
|
|
128
128
|
var day = Math.floor(time / (1000 * 60 * 60 * 24));
|
|
129
129
|
if (day)
|
|
130
|
-
return day
|
|
130
|
+
return "".concat(day, "\u5929\u524D");
|
|
131
131
|
var hour = Math.floor(time / (1000 * 60 * 60));
|
|
132
132
|
if (hour)
|
|
133
|
-
return hour
|
|
133
|
+
return "".concat(hour, "\u5C0F\u65F6\u524D");
|
|
134
134
|
var min = Math.floor(time / (1000 * 60));
|
|
135
135
|
if (min)
|
|
136
|
-
return min
|
|
136
|
+
return "".concat(min, "\u5206\u949F\u524D");
|
|
137
137
|
else
|
|
138
138
|
return '刚刚';
|
|
139
139
|
};
|
|
@@ -48,7 +48,7 @@ var DomClass = /** @class */ (function () {
|
|
|
48
48
|
var value = object[key];
|
|
49
49
|
if (Array.isArray(value)) {
|
|
50
50
|
value.forEach(function (subValue, i) {
|
|
51
|
-
return formData.append(key +
|
|
51
|
+
return formData.append(key + "[".concat(i, "]"), subValue);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
@@ -91,10 +91,10 @@ var NumberClass = /** @class */ (function () {
|
|
|
91
91
|
var price = money.split('.')[0] + '';
|
|
92
92
|
var pricePoint = money.split('.')[1];
|
|
93
93
|
result = price.length > 6 ?
|
|
94
|
-
""
|
|
94
|
+
"".concat(price.substring(0, price.length - 6)).concat(signal).concat(price.substring(price.length - 6, price.length - 3), ",").concat(price.substring(price.length - 3, price.length))
|
|
95
95
|
:
|
|
96
|
-
""
|
|
97
|
-
result = pricePoint ? ""
|
|
96
|
+
"".concat(price.substring(0, price.length - 3)).concat(signal).concat(price.substring(price.length - 3, price.length));
|
|
97
|
+
result = pricePoint ? "".concat(result).concat(signal).concat(pricePoint) : result;
|
|
98
98
|
return result;
|
|
99
99
|
};
|
|
100
100
|
return NumberClass;
|
|
@@ -25,7 +25,7 @@ var ToolsClass = /** @class */ (function () {
|
|
|
25
25
|
body.style.overflow = 'hidden';
|
|
26
26
|
body.style.height = '100%';
|
|
27
27
|
if (className) {
|
|
28
|
-
var dom = document.querySelector("."
|
|
28
|
+
var dom = document.querySelector(".".concat(className));
|
|
29
29
|
dom && dom.addEventListener('touchmove', _this.__setDefault__);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -45,7 +45,7 @@ var ToolsClass = /** @class */ (function () {
|
|
|
45
45
|
body.style.overflow = 'visible';
|
|
46
46
|
body.style.height = 'auto';
|
|
47
47
|
if (className) {
|
|
48
|
-
var dom = document.querySelector("."
|
|
48
|
+
var dom = document.querySelector(".".concat(className));
|
|
49
49
|
dom && dom.removeEventListener('touchmove', _this.__setDefault__);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
@@ -384,9 +384,9 @@ var ToolsClass = /** @class */ (function () {
|
|
|
384
384
|
}
|
|
385
385
|
// 匹配中文、英文、数字
|
|
386
386
|
var regItem = '[\u4e00-\u9fa5a-zA-Z0-9]';
|
|
387
|
-
var regExp = "("
|
|
387
|
+
var regExp = "(".concat(regItem, "{").concat(before, "})").concat(regItem, "*(").concat(regItem, "{").concat(after, "})");
|
|
388
388
|
var reg = new RegExp(regExp);
|
|
389
|
-
return field.replace(reg, "$1"
|
|
389
|
+
return field.replace(reg, "$1".concat("*".repeat(sensitiveLen), "$2"));
|
|
390
390
|
};
|
|
391
391
|
return ToolsClass;
|
|
392
392
|
}());
|
package/package.json
CHANGED
|
@@ -50,11 +50,17 @@ class CookieClass {
|
|
|
50
50
|
* 清除Cookie
|
|
51
51
|
* @param {String} name
|
|
52
52
|
*/
|
|
53
|
-
clearCookie(
|
|
53
|
+
clearCookie({
|
|
54
|
+
name = '',
|
|
55
|
+
path = '/',
|
|
56
|
+
domain = '.jddmoto.com',
|
|
57
|
+
}: ICookie) {
|
|
54
58
|
this.setCookie({
|
|
55
59
|
name,
|
|
56
60
|
value: '',
|
|
57
61
|
exdays: -1,
|
|
62
|
+
path,
|
|
63
|
+
domain
|
|
58
64
|
})
|
|
59
65
|
}
|
|
60
66
|
}
|