amos-apptool 1.0.2 → 1.0.3
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/_clone.js +72 -0
- package/esm/_deepCopy.js +27 -0
- package/esm/_deepEqual.js +7 -0
- package/esm/_fastDeepEqual.js +27 -0
- package/esm/_forOwn.js +11 -0
- package/esm/_isnode.js +3 -0
- package/esm/_omit.js +13 -0
- package/esm/_parseJson.js +9 -0
- package/esm/_pick.js +12 -0
- package/esm/_pickBy.js +14 -0
- package/esm/_queue.js +68 -0
- package/esm/_shallowCopy.js +57 -0
- package/esm/_stringify.js +12 -0
- package/esm/_trim.js +9 -0
- package/esm/_typeOfList.js +25 -0
- package/esm/_uuids.js +54 -0
- package/esm/encrypt/_base64.js +35 -0
- package/esm/encrypt/_md5.js +124 -0
- package/esm/encrypt/des.js +552 -0
- package/esm/index.js +73 -0
- package/esm/math/_keyColor.js +154 -0
- package/esm/math/addition.js +17 -0
- package/esm/math/amountCase.js +13 -0
- package/esm/math/coinFormat.js +7 -0
- package/esm/math/colorUtil.js +259 -0
- package/esm/math/dateTime.js +140 -0
- package/esm/math/divide.js +13 -0
- package/esm/math/mul.js +19 -0
- package/esm/math/pwdStrength.js +5 -0
- package/esm/math/randomColor.js +27 -0
- package/esm/math/subtraction.js +17 -0
- package/esm/merged.js +8 -0
- package/esm/objectPath.js +118 -0
- package/esm/parseText.js +9 -0
- package/esm/pwdPolicy.js +48 -0
- package/esm/random.js +29 -0
- package/esm/shallowEqual.js +24 -0
- package/esm/strUtils.js +88 -0
- package/esm/url/encodeUrl.js +8 -0
- package/esm/url/restfulUrl.js +7 -0
- package/esm/utils.js +347 -0
- package/package.json +5 -6
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var toStr = Object.prototype.toString;
|
|
2
|
+
|
|
3
|
+
function hasOwnProperty(r, t) {
|
|
4
|
+
return null != r && Object.prototype.hasOwnProperty.call(r, t);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var isArray = Array.isArray || function(r) {
|
|
8
|
+
return "[object Array]" === toStr.call(r);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function isEmpty(r) {
|
|
12
|
+
if (!r) return !0;
|
|
13
|
+
if (isArray(r) && 0 === r.length) return !0;
|
|
14
|
+
if ("string" != typeof r) {
|
|
15
|
+
for (var t in r) if (hasOwnProperty(r, t)) return !1;
|
|
16
|
+
return !0;
|
|
17
|
+
}
|
|
18
|
+
return !1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function toString(r) {
|
|
22
|
+
return toStr.call(r);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isObject(r) {
|
|
26
|
+
return "object" == typeof r && "[object Object]" === toString(r);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isBoolean(r) {
|
|
30
|
+
return "boolean" == typeof r || "[object Boolean]" === toString(r);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isNullOrUndefined(r) {
|
|
34
|
+
return null == r;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getKey(r) {
|
|
38
|
+
var t = parseInt(r);
|
|
39
|
+
return t.toString() === r ? t : r;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function factory(r) {
|
|
43
|
+
r = r || {};
|
|
44
|
+
var t = function(r) {
|
|
45
|
+
return Object.keys(t).reduce(function(e, n) {
|
|
46
|
+
return "create" === n || "function" == typeof t[n] && (e[n] = t[n].bind(t, r)),
|
|
47
|
+
e;
|
|
48
|
+
}, {});
|
|
49
|
+
};
|
|
50
|
+
function e(t, e) {
|
|
51
|
+
return r.includeInheritedProps || "number" == typeof e && Array.isArray(t) || hasOwnProperty(t, e);
|
|
52
|
+
}
|
|
53
|
+
function n(r, t) {
|
|
54
|
+
if (e(r, t)) return r[t];
|
|
55
|
+
}
|
|
56
|
+
function i(r, t, e, o) {
|
|
57
|
+
if ("number" == typeof t && (t = [ t ]), !t || 0 === t.length) return r;
|
|
58
|
+
if ("string" == typeof t) return i(r, t.split(".").map(getKey), e, o);
|
|
59
|
+
var u = t[0], f = n(r, u);
|
|
60
|
+
return 1 === t.length ? (!isNullOrUndefined(f) && o || (r[u] = e), f) : (isNullOrUndefined(f) && ("number" == typeof t[1] ? r[u] = [] : r[u] = {}),
|
|
61
|
+
i(r[u], t.slice(1), e, o));
|
|
62
|
+
}
|
|
63
|
+
return t.has = function(t, e) {
|
|
64
|
+
if ("number" == typeof e ? e = [ e ] : "string" == typeof e && (e = e.split(".")),
|
|
65
|
+
!e || 0 === e.length) return !!t;
|
|
66
|
+
for (var n = 0; n < e.length; n++) {
|
|
67
|
+
var i = getKey(e[n]);
|
|
68
|
+
if (!("number" == typeof i && isArray(t) && i < t.length || (r.includeInheritedProps ? i in Object(t) : hasOwnProperty(t, i)))) return !1;
|
|
69
|
+
t = t[i];
|
|
70
|
+
}
|
|
71
|
+
return !0;
|
|
72
|
+
}, t.ensureExists = function(r, t, e) {
|
|
73
|
+
return i(r, t, e, !0);
|
|
74
|
+
}, t.set = function(r, t, e, n) {
|
|
75
|
+
return i(r, t, e, n);
|
|
76
|
+
}, t.insert = function(r, e, n, i) {
|
|
77
|
+
var o = t.get(r, e);
|
|
78
|
+
i = ~~i, isArray(o) || (o = [], t.set(r, e, o)), o.splice(i, 0, n);
|
|
79
|
+
}, t.empty = function(r, n) {
|
|
80
|
+
var i, o;
|
|
81
|
+
if (!isEmpty(n) && (null != r && (i = t.get(r, n)))) {
|
|
82
|
+
if ("string" == typeof i) return t.set(r, n, "");
|
|
83
|
+
if (isBoolean(i)) return t.set(r, n, !1);
|
|
84
|
+
if ("number" == typeof i) return t.set(r, n, 0);
|
|
85
|
+
if (isArray(i)) i.length = 0; else {
|
|
86
|
+
if (!isObject(i)) return t.set(r, n, null);
|
|
87
|
+
for (o in i) e(i, o) && delete i[o];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, t.push = function(r, e) {
|
|
91
|
+
var n = t.get(r, e);
|
|
92
|
+
isArray(n) || (n = [], t.set(r, e, n)), n.push.apply(n, Array.prototype.slice.call(arguments, 2));
|
|
93
|
+
}, t.coalesce = function(r, e, n) {
|
|
94
|
+
for (var i, o = 0, u = e.length; o < u; o++) if (void 0 !== (i = t.get(r, e[o]))) return i;
|
|
95
|
+
return n;
|
|
96
|
+
}, t.get = function(r, e, i) {
|
|
97
|
+
if ("number" == typeof e && (e = [ e ]), !e || 0 === e.length) return r;
|
|
98
|
+
if (null == r) return i;
|
|
99
|
+
if ("string" == typeof e) return t.get(r, e.split("."), i);
|
|
100
|
+
var o = getKey(e[0]), u = n(r, o);
|
|
101
|
+
return void 0 === u ? i : 1 === e.length ? u : t.get(r[o], e.slice(1), i);
|
|
102
|
+
}, t.del = function(r, n) {
|
|
103
|
+
if ("number" == typeof n && (n = [ n ]), null == r) return r;
|
|
104
|
+
if (isEmpty(n)) return r;
|
|
105
|
+
if ("string" == typeof n) return t.del(r, n.split("."));
|
|
106
|
+
var i = getKey(n[0]);
|
|
107
|
+
return e(r, i) ? 1 !== n.length ? t.del(r[i], n.slice(1)) : (isArray(r) ? r.splice(i, 1) : delete r[i],
|
|
108
|
+
r) : r;
|
|
109
|
+
}, t;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
var mod = factory();
|
|
113
|
+
|
|
114
|
+
mod.create = factory, mod.withInheritedProps = factory({
|
|
115
|
+
includeInheritedProps: !0
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export default mod;
|
package/esm/parseText.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import utils from "./utils";
|
|
2
|
+
|
|
3
|
+
var defaultRE = /\{((?:.|\n)+?)\}/g;
|
|
4
|
+
|
|
5
|
+
export default function parseText(e, t, i, n) {
|
|
6
|
+
return i || (i = defaultRE), e && e.replace ? e.replace(i, function(e, i) {
|
|
7
|
+
return utils.isUndefined(t[i]) ? !utils.isUndefined(t[i]) || utils.isUndefined(n) && "" !== n ? e : n : t[i];
|
|
8
|
+
}) : e;
|
|
9
|
+
}
|
package/esm/pwdPolicy.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _uuid from "./_uuids";
|
|
2
|
+
|
|
3
|
+
import _Base64 from "./encrypt/_base64";
|
|
4
|
+
|
|
5
|
+
import md5 from "./encrypt/_md5";
|
|
6
|
+
|
|
7
|
+
const _Coder = {
|
|
8
|
+
encrypt: e => (new _Base64).encode(e),
|
|
9
|
+
decrypt(e) {
|
|
10
|
+
var r = (new _Base64).decode(e);
|
|
11
|
+
return r = (r = escape(r)).replace(/%00/g, ""), r = unescape(r);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var normalPolicy = function(e) {
|
|
16
|
+
e || (e = "");
|
|
17
|
+
var r = _uuid.uuid(16);
|
|
18
|
+
return e += r, {
|
|
19
|
+
password: _Coder.encrypt(e),
|
|
20
|
+
secretKey: r
|
|
21
|
+
};
|
|
22
|
+
}, advancePolicy = function(e, r) {
|
|
23
|
+
return e || (e = ""), r || (r = _uuid.uuid(32)), e += r, {
|
|
24
|
+
password: _Coder.encrypt(e),
|
|
25
|
+
secretKey: r
|
|
26
|
+
};
|
|
27
|
+
}, useMd5Policy = function(e, r) {
|
|
28
|
+
return e || (e = ""), r || (r = _uuid.uuid(32)), {
|
|
29
|
+
password: md5(e, r),
|
|
30
|
+
secretKey: r
|
|
31
|
+
};
|
|
32
|
+
}, useMd5Policy2 = function(e, r) {
|
|
33
|
+
e || (e = ""), r || (r = _uuid.uuid(32));
|
|
34
|
+
var o = md5(e);
|
|
35
|
+
return o += r, {
|
|
36
|
+
password: _Coder.encrypt(o),
|
|
37
|
+
secretKey: r
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const pwdPolicy = {
|
|
42
|
+
normalPolicy: normalPolicy,
|
|
43
|
+
advancePolicy: advancePolicy,
|
|
44
|
+
useMd5Policy: useMd5Policy,
|
|
45
|
+
useMd5Policy2: useMd5Policy2
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default pwdPolicy;
|
package/esm/random.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function randomInt(r, n) {
|
|
2
|
+
return null == n && (n = r, r = 0), r + Math.floor(Math.random() * (n - r + 1));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function random(r) {
|
|
6
|
+
r || (r = 6);
|
|
7
|
+
for (var n = "", o = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", a = 0; a < r; a++) n += o.charAt(randomInt(0, 60));
|
|
8
|
+
return n;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function randomOrderNumber(r, n) {
|
|
12
|
+
if (!Array.from) {
|
|
13
|
+
for (var o = [], a = r; a < n + 1; a++) o.push(a);
|
|
14
|
+
return o;
|
|
15
|
+
}
|
|
16
|
+
return Array.from({
|
|
17
|
+
length: n - r + 1
|
|
18
|
+
}, function(n, o) {
|
|
19
|
+
return r + o;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const $random = {
|
|
24
|
+
random: random,
|
|
25
|
+
randomInt: randomInt,
|
|
26
|
+
randomOrderNumber: randomOrderNumber
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default $random;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const shallowEqual = function(t, e) {
|
|
2
|
+
if (t === e) return !0;
|
|
3
|
+
if ("object" != typeof t || null === t || "object" != typeof e || null === e) return !1;
|
|
4
|
+
var r = Object.keys(t), n = Object.keys(e);
|
|
5
|
+
if (r.length !== n.length) return !1;
|
|
6
|
+
for (var o = Object.prototype.hasOwnProperty.bind(e), l = 0; l < r.length; l++) if (!o(r[l]) || t[r[l]] !== e[r[l]]) return !1;
|
|
7
|
+
return !0;
|
|
8
|
+
}, customEqual = function(t, e, r, n) {
|
|
9
|
+
var o = r ? r.call(n, t, e) : void 0;
|
|
10
|
+
if (void 0 !== o) return !!o;
|
|
11
|
+
if (t === e) return !0;
|
|
12
|
+
if ("object" != typeof t || !t || "object" != typeof e || !e) return !1;
|
|
13
|
+
var l = Object.keys(t), u = Object.keys(e);
|
|
14
|
+
if (l.length !== u.length) return !1;
|
|
15
|
+
for (var f = Object.prototype.hasOwnProperty.bind(e), i = 0; i < l.length; i++) {
|
|
16
|
+
var a = l[i];
|
|
17
|
+
if (!f(a)) return !1;
|
|
18
|
+
var c = t[a], b = e[a];
|
|
19
|
+
if ((!1 === (o = r ? r.call(n, c, b, a) : void 0) || void 0 === o) && c !== b) return !1;
|
|
20
|
+
}
|
|
21
|
+
return !0;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { shallowEqual, customEqual };
|
package/esm/strUtils.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { deepCopy } from "./_deepCopy";
|
|
2
|
+
|
|
3
|
+
import utils from "./utils";
|
|
4
|
+
|
|
5
|
+
const strUtils = {
|
|
6
|
+
toCapitalStr: function(t) {
|
|
7
|
+
return utils.isNil(t) ? t : utils.isString(t) ? t[0].toUpperCase() + t.slice(1, t.length) : t;
|
|
8
|
+
},
|
|
9
|
+
camelCase: function(t) {
|
|
10
|
+
return t.charAt(0).toUpperCase() + t.slice(1).replace(/-(\w)/g, function(t, r) {
|
|
11
|
+
return r.toUpperCase();
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
transCamel: function(t) {
|
|
15
|
+
return (t = t.toLowerCase()).replace(/-(\w)/g, function(t, r) {
|
|
16
|
+
return r.toUpperCase();
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
capFirst: function(t) {
|
|
20
|
+
return t && "" !== t ? t.replace(/(\w)/, function(t) {
|
|
21
|
+
return t.toUpperCase();
|
|
22
|
+
}) : t;
|
|
23
|
+
},
|
|
24
|
+
hashCode: function(t) {
|
|
25
|
+
if (t) {
|
|
26
|
+
var r = function(t) {
|
|
27
|
+
return t > 2147483647 || t < -2147483648 ? 4294967295 & t : t;
|
|
28
|
+
};
|
|
29
|
+
t = t.toString();
|
|
30
|
+
for (var e = 0, n = 0; n < t.length; n++) e = r(e = 31 * e + t.charCodeAt(n));
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
},
|
|
35
|
+
dealScaleAndUnit: function(t, r) {
|
|
36
|
+
var e = deepCopy(r);
|
|
37
|
+
if (e || (e = {
|
|
38
|
+
selfenable: !1,
|
|
39
|
+
fixnumber: 2,
|
|
40
|
+
thousandsplitchar: !0
|
|
41
|
+
}), !utils.isFloat(t)) return t;
|
|
42
|
+
var n = "";
|
|
43
|
+
"-" == (t = t.toString()).charAt(0) && (n = "-", t = t.substring(1, t.length)),
|
|
44
|
+
null != e.selfscale && "" != e.selfscale || null != e.selfunit && "" != e.selfunit || (e.selfscale = "1000,1000,1000",
|
|
45
|
+
e.selfunit = "K,M,B");
|
|
46
|
+
var l = 2;
|
|
47
|
+
null != e.fixnumber && "NaN" != parseInt(e.fixnumber).toString() && (l = parseInt(e.fixnumber));
|
|
48
|
+
var a = "";
|
|
49
|
+
if (null != e.suffix && (a = e.suffix), e.selfenable) {
|
|
50
|
+
var i = e.selfunit;
|
|
51
|
+
null == i && (i = "");
|
|
52
|
+
var s = e.selfscale;
|
|
53
|
+
if (null == s || "" == s.toString().trim()) a = i + a; else {
|
|
54
|
+
for (var o = i.split(","), f = s.split(","), u = [], p = !0, h = 0; h < f.length; h++) if (null != f[h] && "NaN" != parseFloat(f[h]).toString()) {
|
|
55
|
+
if ("NaN" == parseFloat(f[h]).toString() || "0" == parseFloat(f[h]).toString() || parseFloat(f[h]) < 0) {
|
|
56
|
+
p = !1;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
0 == u.length ? u[0] = f[h] : u[u.length] = parseFloat(f[h]) * parseFloat(u[u.length - 1]);
|
|
60
|
+
}
|
|
61
|
+
if (f = u, p) for (var c = f.length - 1; c >= 0; c--) if (!(c > o.length - 1)) {
|
|
62
|
+
null == o[c] && (o[c] = "");
|
|
63
|
+
var g = parseFloat(t) / f[c];
|
|
64
|
+
if (t.indexOf(".") > -1) {
|
|
65
|
+
var d = t.substr(t.indexOf(".") + 1, t.length).length;
|
|
66
|
+
g = parseFloat(t) * Math.pow(10, d) / (f[c] * Math.pow(10, d));
|
|
67
|
+
}
|
|
68
|
+
if (Math.abs(g) >= 1) {
|
|
69
|
+
t = g, a = o[c] + a;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return l > -1 && (t = parseFloat(t).toFixed(l) + ""), e.fillzero || (t = parseFloat(t) + ""),
|
|
76
|
+
(null == e.thousandsplitchar || e.thousandsplitchar) && (t = t.indexOf(".") > -1 ? t.substr(0, t.indexOf(".")).replace(/\d{1,3}(?=(\d{3})+$)/g, "$&,") + t.substr(t.indexOf("."), t.length) : t.replace(/\d{1,3}(?=(\d{3})+$)/g, "$&,")),
|
|
77
|
+
t = n + t, null != e.prefix && (t = e.prefix + t), t += a;
|
|
78
|
+
},
|
|
79
|
+
toUTF8(t) {
|
|
80
|
+
let r, e, n, l = "";
|
|
81
|
+
for (e = t.length, r = 0; r < e; r++) n = t.charCodeAt(r), n >= 1 && n <= 127 ? l += t.charAt(r) : n > 2047 ? (l += String.fromCharCode(224 | n >> 12 & 15),
|
|
82
|
+
l += String.fromCharCode(128 | n >> 6 & 63), l += String.fromCharCode(128 | 63 & n)) : (l += String.fromCharCode(192 | n >> 6 & 31),
|
|
83
|
+
l += String.fromCharCode(128 | 63 & n));
|
|
84
|
+
return l;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default strUtils;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var encodeLen = 8;
|
|
2
|
+
|
|
3
|
+
export default function(e) {
|
|
4
|
+
const g = [ /[+]/g, /[ ]/g, /[\/]/g, /[\?]/g, /[#]/g, /[&]/g, /[=]/g ], n = [ "%2B", "%20", "%2F", "%3F", "%23", "%26", "%3D" ];
|
|
5
|
+
e = e.replace(/[%]/g, "%25");
|
|
6
|
+
for (let r = 0; r < encodeLen - 1; r++) e = e.replace(g[r], n[r]);
|
|
7
|
+
return e;
|
|
8
|
+
}
|
package/esm/utils.js
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import _typeOfList from "./_typeOfList";
|
|
2
|
+
|
|
3
|
+
var ObjProto = Object.prototype, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, nativeIsArray = Array.isArray, nativeKeys = Object.keys, BUILTIN_OBJECT = _typeOfList.BUILTIN_OBJECT, TYPED_ARRAY = _typeOfList.TYPED_ARRAY, property = function(t) {
|
|
4
|
+
return function(e) {
|
|
5
|
+
return null == e ? void 0 : e[t];
|
|
6
|
+
};
|
|
7
|
+
}, MAX_ARRAY_INDEX = Math.pow(2, 53) - 1, getLength = property("length"), isArrayLike = function(t) {
|
|
8
|
+
var e = getLength(t);
|
|
9
|
+
return "number" == typeof e && e >= 0 && e <= MAX_ARRAY_INDEX;
|
|
10
|
+
}, isNumber = function(t) {
|
|
11
|
+
if (isArray(t)) return !1;
|
|
12
|
+
if (isObject(t)) return !1;
|
|
13
|
+
var e = /^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/.test(t), n = "number" == typeof t && !isNaN(t);
|
|
14
|
+
return e || n;
|
|
15
|
+
}, isENumber = function(t) {
|
|
16
|
+
if ("number" == typeof t) return !0;
|
|
17
|
+
if (isNumber(t)) return !0;
|
|
18
|
+
if (isString(t) && (t.indexOf("e") > -1 || t.indexOf("E") > -1)) {
|
|
19
|
+
var e = Number(t);
|
|
20
|
+
return isNumber(e);
|
|
21
|
+
}
|
|
22
|
+
return !1;
|
|
23
|
+
}, isFloat = function(t) {
|
|
24
|
+
return /^-?\d+(\.\d+)?$/.test(t);
|
|
25
|
+
}, isOpacity = function(t) {
|
|
26
|
+
return /^-?\d+(\.\d+)?$/.test(t);
|
|
27
|
+
}, toFloat = function(t) {
|
|
28
|
+
return isNumber(t) ? Number(t) : Number(0);
|
|
29
|
+
}, isString = function(t) {
|
|
30
|
+
return "[object String]" === toString.call(t);
|
|
31
|
+
}, isArray = nativeIsArray || function(t) {
|
|
32
|
+
return "[object Array]" === toString.call(t);
|
|
33
|
+
}, isArguments = function(t) {
|
|
34
|
+
return "[object Arguments]" === toString.call(t);
|
|
35
|
+
}, isObject = function(t) {
|
|
36
|
+
var e = typeof t;
|
|
37
|
+
return "function" === e || "object" === e && !!t;
|
|
38
|
+
}, isOnlyObject = function(t) {
|
|
39
|
+
return "object" === typeof t && "[object Object]" === toString.call(t) && !!t;
|
|
40
|
+
}, isBoolean = function(t) {
|
|
41
|
+
return !0 === t || !1 === t || "[object Boolean]" === toString.call(t);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const isFunction = function(t) {
|
|
45
|
+
return "[object Function]" === toString.call(t);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var isNull = function(t) {
|
|
49
|
+
return null === t;
|
|
50
|
+
}, isUndefined = function(t) {
|
|
51
|
+
return void 0 === t;
|
|
52
|
+
}, isNil = function(t) {
|
|
53
|
+
return null == t;
|
|
54
|
+
}, isBlank = function(t) {
|
|
55
|
+
return isNil(t) || "" === t;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function isNullOrUndefined(t) {
|
|
59
|
+
return null == t;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const isEmptyObject = function(t) {
|
|
63
|
+
if (t) for (var e in t) if (hasOwnProperty.call(t, e)) return !1;
|
|
64
|
+
return !0;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var has = function(t, e) {
|
|
68
|
+
if (!isArray(e)) return null != t && Object.prototype.hasOwnProperty.call(t, e);
|
|
69
|
+
for (var n = e.length, r = 0; r < n; r++) {
|
|
70
|
+
var i = e[r];
|
|
71
|
+
if (null == t || !Object.prototype.hasOwnProperty.call(t, i)) return !1;
|
|
72
|
+
t = t[i];
|
|
73
|
+
}
|
|
74
|
+
return !!n;
|
|
75
|
+
}, keys = function(t) {
|
|
76
|
+
if (!isObject(t)) return [];
|
|
77
|
+
if (nativeKeys) return nativeKeys(t);
|
|
78
|
+
var e = [];
|
|
79
|
+
for (var n in t) has(t, n) && e.push(n);
|
|
80
|
+
return e;
|
|
81
|
+
}, values = function(t) {
|
|
82
|
+
for (var e = keys(t), n = e.length, r = Array(n), i = 0; i < n; i++) r[i] = t[e[i]];
|
|
83
|
+
return r;
|
|
84
|
+
}, noop = function() {}, isEmpty = function(t) {
|
|
85
|
+
return null == t || (isArrayLike(t) && (isArray(t) || isString(t) || isArguments(t)) ? 0 === t.length : 0 === keys(t).length);
|
|
86
|
+
}, isElement = function(t) {
|
|
87
|
+
return !(!t || 1 !== t.nodeType);
|
|
88
|
+
}, isHTMLElement = function(t) {
|
|
89
|
+
return window.HTMLElement || window.Element ? t instanceof (window.HTMLElement || window.Element) : t && "object" == typeof n && 1 === t.nodeType && "string" == typeof t.nodeName;
|
|
90
|
+
}, isSVGElement = function(t) {
|
|
91
|
+
return window.SVGElement && t instanceof window.SVGElement;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
function isDom(t) {
|
|
95
|
+
return "object" == typeof t && "number" == typeof t.nodeType && "object" == typeof t.ownerDocument;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isUrl(t) {
|
|
99
|
+
return isString(t) && (/^https?:\/\/(?!\-)(?:(([0-9]{1,3}\.){3}[0-9]{1,3}))(:[0-9]{1,4}\/)?/.test(t) || /^https?:\/\/(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}/.test(t) || /^https?:\/\/localhost.*/.test(t));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function isBuiltInObject(t) {
|
|
103
|
+
return !!BUILTIN_OBJECT[toString.call(t)];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var null2default = function(t) {
|
|
107
|
+
return isNull(t) || isUndefined(t) ? "" : t;
|
|
108
|
+
}, isJson = function(t) {
|
|
109
|
+
return "object" == typeof t && "[object object]" === toString.call(t).toLowerCase() && !t.length;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
function isSymbol(t) {
|
|
113
|
+
return "symbol" == typeof t;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isDate(t) {
|
|
117
|
+
return "[object Date]" === toString.call(t);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function _isJSON(t) {
|
|
121
|
+
return !!isString(t) && (t = t.replace(/\s/g, "").replace(/\n|\r/, ""), /^\{(.*?)\}$/.test(t) ? /"(.*?)":(.*?)/g.test(t) : !!/^\[(.*?)\]$/.test(t) && t.replace(/^\[/, "").replace(/\]$/, "").replace(/},{/g, "}\n{").split(/\n/).map(function(t) {
|
|
122
|
+
return _isJSON(t);
|
|
123
|
+
}).reduce(function(t, e) {
|
|
124
|
+
return !!e;
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var stringIsJson = function(t) {
|
|
129
|
+
try {
|
|
130
|
+
let e = JSON.parse(t);
|
|
131
|
+
return isString(e) && (e = JSON.parse(e)), !(isNil(e) || !isArray(e) && !isObject(e));
|
|
132
|
+
} catch (e) {
|
|
133
|
+
return _isJSON(t);
|
|
134
|
+
}
|
|
135
|
+
}, isKeyInObject = function(t, e) {
|
|
136
|
+
if (isNil(e) || !isObject(e)) return !1;
|
|
137
|
+
isString(t) && (t = [ t ]);
|
|
138
|
+
var n = 0;
|
|
139
|
+
return t.forEach(function(t) {
|
|
140
|
+
t in e && n++;
|
|
141
|
+
}), t.length === n;
|
|
142
|
+
}, isOwnKeyInObject = function(t, e) {
|
|
143
|
+
if (isNil(e) || !isObject(e)) return !1;
|
|
144
|
+
isString(t) && (t = [ t ]);
|
|
145
|
+
var n = 0;
|
|
146
|
+
return t.forEach(function(t) {
|
|
147
|
+
t in e && hasOwnProperty.call(e, t) && n++;
|
|
148
|
+
}), t.length === n;
|
|
149
|
+
}, simpleEqual = function(t, e) {
|
|
150
|
+
if (t === e) return !0;
|
|
151
|
+
if ("object" != typeof t || null === t || "object" != typeof e || null === e) return !1;
|
|
152
|
+
var n = nativeKeys(t), r = nativeKeys(e);
|
|
153
|
+
if (n.length !== r.length) return !1;
|
|
154
|
+
for (var i = hasOwnProperty.bind(e), o = 0; o < n.length; o++) if (!i(n[o]) || t[n[o]] !== e[n[o]]) return !1;
|
|
155
|
+
return !0;
|
|
156
|
+
}, isImageSrc = function() {
|
|
157
|
+
var t = /data:image\/(jpe?g|png|gif|bmp|ico|tga|svg(\+xml)?);base64,/i, e = /.(jpe?g|png|gif|bmp|ico|tga|svg)(\?.*)?$/i;
|
|
158
|
+
return function(n) {
|
|
159
|
+
return t.test(n) || e.test(n);
|
|
160
|
+
};
|
|
161
|
+
}(), isGIF = function() {
|
|
162
|
+
var t = /data:image\/(GIF|gif);base64,/i, e = /.(GIF|gif)(\?.*)?$/i;
|
|
163
|
+
return function(n) {
|
|
164
|
+
return t.test(n) || e.test(n);
|
|
165
|
+
};
|
|
166
|
+
}(), encodeNumber = function(t, e = 3, n = 4, r = "*") {
|
|
167
|
+
const i = String(t), o = e + n, s = r.repeat(n);
|
|
168
|
+
return i.length > o ? i.substr(0, e) + s + i.substr(o) : i.substr(0, e) + s;
|
|
169
|
+
}, getFileExtension = function(t) {
|
|
170
|
+
if (t) {
|
|
171
|
+
const e = t.lastIndexOf(".");
|
|
172
|
+
return e > 0 ? t.substring(e + 1) : "";
|
|
173
|
+
}
|
|
174
|
+
return "";
|
|
175
|
+
}, fileSizeToByte = function(t) {
|
|
176
|
+
var e = {
|
|
177
|
+
t: 1099511627776,
|
|
178
|
+
g: 1073741824,
|
|
179
|
+
m: 1048576,
|
|
180
|
+
k: 1024
|
|
181
|
+
};
|
|
182
|
+
if (!t) return 0;
|
|
183
|
+
if (!isString(t)) return t;
|
|
184
|
+
t = t.toLocaleLowerCase().replace(/\s*/g, "");
|
|
185
|
+
const n = (t = /^([0-9\.]+)([tgmk]?)b?$/i.exec(t))[2];
|
|
186
|
+
return t = +t[1], e.hasOwnProperty(n) && (t *= e[n]), t;
|
|
187
|
+
}, some = function(t, e) {
|
|
188
|
+
if (null == t) throw new TypeError;
|
|
189
|
+
var n = Object(t), r = n.length >>> 0;
|
|
190
|
+
if ("function" != typeof e) throw new TypeError;
|
|
191
|
+
for (var i = arguments.length >= 3 ? arguments[2] : void 0, o = 0; o < r; o++) if (o in n && e.call(i, n[o], o, n)) return !0;
|
|
192
|
+
return !1;
|
|
193
|
+
}, every = function(t, e, n) {
|
|
194
|
+
var r, i;
|
|
195
|
+
if (null == t) throw new TypeError("arr is null or not defined");
|
|
196
|
+
var o = Object(t), s = o.length >>> 0;
|
|
197
|
+
if ("function" != typeof e) throw new TypeError;
|
|
198
|
+
for (arguments.length > 2 && (r = n), i = 0; i < s; ) {
|
|
199
|
+
var u;
|
|
200
|
+
if (i in o) if (u = o[i], !e.call(r, u, i, o)) return !1;
|
|
201
|
+
i++;
|
|
202
|
+
}
|
|
203
|
+
return !0;
|
|
204
|
+
}, reduce = function(t, e) {
|
|
205
|
+
if (null === t) throw new TypeError("Array.prototype.reduce called on null or undefined");
|
|
206
|
+
if ("function" != typeof e) throw new TypeError(e + " is not a function");
|
|
207
|
+
var n, r = Object(t), i = r.length >>> 0, o = 0;
|
|
208
|
+
if (arguments.length >= 3) n = arguments[2]; else {
|
|
209
|
+
for (;o < i && !(o in r); ) o++;
|
|
210
|
+
if (o >= i) throw new TypeError("Reduce of empty array with no initial value");
|
|
211
|
+
n = r[o++];
|
|
212
|
+
}
|
|
213
|
+
for (;o < i; ) o in r && (n = e(n, r[o], o, r)), o++;
|
|
214
|
+
return n;
|
|
215
|
+
}, parse2string = function(t) {
|
|
216
|
+
return isEmpty(t) ? "" : JSON.stringify(t);
|
|
217
|
+
}, parse2object = function(t) {
|
|
218
|
+
return isEmpty(t) ? null : JSON.parse(t);
|
|
219
|
+
}, dataToArray = function(t) {
|
|
220
|
+
return isArray(t) ? t : [ t ];
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
function clone(t) {
|
|
224
|
+
if (null == t || "object" != typeof t) return t;
|
|
225
|
+
let e = t;
|
|
226
|
+
const n = toString.call(t);
|
|
227
|
+
if ("[object Array]" === n) {
|
|
228
|
+
e = [];
|
|
229
|
+
for (let n = 0, r = t.length; n < r; n++) e[n] = clone(t[n]);
|
|
230
|
+
} else if (TYPED_ARRAY[n]) {
|
|
231
|
+
const n = t.constructor;
|
|
232
|
+
if (t.constructor.from) e = n.from(t); else {
|
|
233
|
+
e = new n(t.length);
|
|
234
|
+
for (let n = 0, r = t.length; n < r; n++) e[n] = clone(t[n]);
|
|
235
|
+
}
|
|
236
|
+
} else if (!BUILTIN_OBJECT[n] && !isDom(t)) {
|
|
237
|
+
e = {};
|
|
238
|
+
for (let n in t) t.hasOwnProperty(n) && (e[n] = clone(t[n]));
|
|
239
|
+
}
|
|
240
|
+
return e;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function merge(t, e, n) {
|
|
244
|
+
if (!isObject(e) || !isObject(t)) return n ? clone(e) : t;
|
|
245
|
+
for (var r in e) if (e.hasOwnProperty(r)) {
|
|
246
|
+
var i = t[r], o = e[r];
|
|
247
|
+
!isObject(o) || !isObject(i) || isArray(o) || isArray(i) || isDom(o) || isDom(i) || isBuiltInObject(o) || isBuiltInObject(i) ? !n && r in t || (t[r] = clone(e[r])) : merge(i, o, n);
|
|
248
|
+
}
|
|
249
|
+
return t;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function mergeAll(t, e) {
|
|
253
|
+
for (var n = t[0], r = 1, i = t.length; r < i; r++) n = merge(n, t[r], e);
|
|
254
|
+
return n;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function subObjectEqual(t, e) {
|
|
258
|
+
if (isEmpty(t) || isEmpty(e)) return !0;
|
|
259
|
+
if (t === e) return !0;
|
|
260
|
+
return !Object.keys(e).some(n => n in t && e[n] !== t[n]);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function isPromise(t) {
|
|
264
|
+
return !isNull(t) && "object" == typeof t && (t instanceof Promise || "[object Promise]" === toString.call(t) || t.then && isFunction(t.then));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function isRegExp(t) {
|
|
268
|
+
return !isNull(t) && "object" == typeof t && (t instanceof RegExp || "[object RegExp]" === toString.call(t));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function slpitArray(t, e) {
|
|
272
|
+
const n = t.length, r = [];
|
|
273
|
+
if (e <= n) {
|
|
274
|
+
const i = Math.ceil(n / e);
|
|
275
|
+
for (let n = 0; n < e; n++) {
|
|
276
|
+
const e = t.slice(n * i, n * i + i);
|
|
277
|
+
r.push(e);
|
|
278
|
+
}
|
|
279
|
+
} else r.push(t.slice());
|
|
280
|
+
return r;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function checkFileName(t, e = 259) {
|
|
284
|
+
if (isNil(t)) return !1;
|
|
285
|
+
if (!isString(t) && !isNumber(t)) return !1;
|
|
286
|
+
if ((t = String(t)).length > e) return !1;
|
|
287
|
+
return !/[\\/:\*\?"<>\|]/g.test(t) && (!t.endsWith(" ") && !t.startsWith(" ") && ("." !== t && " " !== t));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const utils = {
|
|
291
|
+
isString: isString,
|
|
292
|
+
isArray: isArray,
|
|
293
|
+
isObject: isObject,
|
|
294
|
+
isOnlyObject: isOnlyObject,
|
|
295
|
+
isBoolean: isBoolean,
|
|
296
|
+
isFunction: isFunction,
|
|
297
|
+
isNumber: isNumber,
|
|
298
|
+
isENumber: isENumber,
|
|
299
|
+
isFloat: isFloat,
|
|
300
|
+
isOpacity: isOpacity,
|
|
301
|
+
toFloat: toFloat,
|
|
302
|
+
isNull: isNull,
|
|
303
|
+
isUndefined: isUndefined,
|
|
304
|
+
isNil: isNil,
|
|
305
|
+
isBlank: isBlank,
|
|
306
|
+
isNullOrUndefined: isNullOrUndefined,
|
|
307
|
+
has: has,
|
|
308
|
+
values: values,
|
|
309
|
+
noop: noop,
|
|
310
|
+
isEmpty: isEmpty,
|
|
311
|
+
isEmptyObject: isEmptyObject,
|
|
312
|
+
isElement: isElement,
|
|
313
|
+
isHTMLElement: isHTMLElement,
|
|
314
|
+
isSVGElement: isSVGElement,
|
|
315
|
+
isDom: isDom,
|
|
316
|
+
isUrl: isUrl,
|
|
317
|
+
isBuiltInObject: isBuiltInObject,
|
|
318
|
+
null2default: null2default,
|
|
319
|
+
isJson: isJson,
|
|
320
|
+
isSymbol: isSymbol,
|
|
321
|
+
isDate: isDate,
|
|
322
|
+
stringIsJson: stringIsJson,
|
|
323
|
+
isKeyInObject: isKeyInObject,
|
|
324
|
+
isOwnKeyInObject: isOwnKeyInObject,
|
|
325
|
+
simpleEqual: simpleEqual,
|
|
326
|
+
isImageSrc: isImageSrc,
|
|
327
|
+
isGIF: isGIF,
|
|
328
|
+
encodeNumber: encodeNumber,
|
|
329
|
+
getFileExtension: getFileExtension,
|
|
330
|
+
fileSizeToByte: fileSizeToByte,
|
|
331
|
+
some: some,
|
|
332
|
+
every: every,
|
|
333
|
+
reduce: reduce,
|
|
334
|
+
parse2string: parse2string,
|
|
335
|
+
parse2object: parse2object,
|
|
336
|
+
dataToArray: dataToArray,
|
|
337
|
+
clone: clone,
|
|
338
|
+
merge: merge,
|
|
339
|
+
mergeAll: mergeAll,
|
|
340
|
+
subObjectEqual: subObjectEqual,
|
|
341
|
+
isPromise: isPromise,
|
|
342
|
+
isRegExp: isRegExp,
|
|
343
|
+
slpitArray: slpitArray,
|
|
344
|
+
checkFileName: checkFileName
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export default utils;
|