amos-tool 1.4.4 → 1.4.8
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/.prettierignore +2 -2
- package/.prettierrc +50 -50
- package/README.md +667 -653
- package/apis/objectPath.md +129 -129
- package/index.d.ts +50 -5
- package/index.js +3 -3
- package/lib/_browser.js +10 -8
- package/lib/_clone.js +67 -62
- package/lib/_cookie.js +35 -32
- package/lib/_deepCopy.js +17 -29
- package/lib/_deepEqual.js +6 -13
- package/lib/_fastDeepEqual.js +28 -44
- package/lib/_flashSupport.js +13 -10
- package/lib/_forOwn.js +8 -7
- package/lib/_funcThrottle.js +16 -15
- package/lib/_isnode.js +2 -1
- package/lib/_list.js +55 -67
- package/lib/_object.assign.js +14 -24
- package/lib/_object.entries.js +6 -5
- package/lib/_object.values.js +5 -4
- package/lib/_omit.js +12 -12
- package/lib/_parseJson.js +7 -6
- package/lib/_pick.js +14 -0
- package/lib/_queue.js +24 -21
- package/lib/_shallowCopy.js +24 -23
- package/lib/_stringify.js +14 -17
- package/lib/_supportWs.js +5 -5
- package/lib/_trim.js +5 -4
- package/lib/_typeOfList.js +22 -21
- package/lib/_uuids.js +30 -35
- package/lib/amostool.js +15 -63
- package/lib/array2tree.js +9 -10
- package/lib/arrayFilter.js +17 -20
- package/lib/arrayUtils.js +13 -11
- package/lib/browser/Cookie.js +34 -35
- package/lib/browser/indexDB.js +71 -82
- package/lib/browserSupport.js +76 -71
- package/lib/completeUnit.js +7 -4
- package/lib/consts.js +2 -1
- package/lib/dom/canvas2img.js +61 -73
- package/lib/dom/canvasTools.js +9 -14
- package/lib/dom/downloadFile.js +15 -12
- package/lib/dom/eventHelper.js +8 -6
- package/lib/dom/fileBlob.js +14 -14
- package/lib/dom/fileSaveAs.js +54 -61
- package/lib/dom/getFontSize.js +7 -10
- package/lib/dom/minfyImg.js +30 -25
- package/lib/encrypt/_base64.js +32 -25
- package/lib/encrypt/_md5.js +68 -31
- package/lib/encrypt/des.js +426 -363
- package/lib/extra/_common.js +119 -166
- package/lib/extra/filterNull.js +3 -2
- package/lib/extra/find.js +10 -11
- package/lib/extra/index.js +4 -3
- package/lib/extra/memo.js +18 -0
- package/lib/extra/pathToTree.js +48 -42
- package/lib/extra/pwdStrength.js +4 -2
- package/lib/extra/sortBy.js +28 -30
- package/lib/flat.js +15 -0
- package/lib/locationParams.js +94 -99
- package/lib/log.js +20 -26
- package/lib/math/_keyColor.js +154 -0
- package/lib/math/addition.js +9 -7
- package/lib/math/amountCase.js +8 -12
- package/lib/math/coinFormat.js +7 -5
- package/lib/math/colorUtil.js +96 -92
- package/lib/math/dateTime.js +76 -94
- package/lib/math/operations.js +33 -37
- package/lib/math/pwdStrength.js +4 -2
- package/lib/math/randomColor.js +17 -5
- package/lib/math/subtraction.js +10 -9
- package/lib/merged.js +9 -9
- package/lib/objectPath.js +88 -95
- package/lib/parseText.js +8 -7
- package/lib/png/Identicon.js +36 -38
- package/lib/png/pnglib.js +58 -32
- package/lib/png/randomPic.js +9 -12
- package/lib/positionFactory.js +25 -80
- package/lib/pwdPolicy.js +27 -31
- package/lib/qs/_assign.js +7 -5
- package/lib/qs/_merge.js +19 -28
- package/lib/qs/_tools.js +3 -2
- package/lib/qs/formats.js +6 -5
- package/lib/qs/index.js +4 -4
- package/lib/qs/parse.js +55 -50
- package/lib/qs/stringify.js +55 -77
- package/lib/qs/utils.js +69 -88
- package/lib/random.js +5 -4
- package/lib/shallowEqual.js +24 -34
- package/lib/store.js +93 -98
- package/lib/strUtils.js +51 -42
- package/lib/tableFilter.js +178 -169
- package/lib/throttleDebounce.js +18 -22
- package/lib/url/encodeUrl.js +5 -4
- package/lib/url/restfulUrl.js +8 -7
- package/lib/utils.js +169 -223
- package/lib/xss/htmlEncode.js +3 -2
- package/lib/xss/implementEncode.js +36 -37
- package/lib/xss/index.js +4 -3
- package/package.json +9 -8
package/lib/qs/utils.js
CHANGED
|
@@ -1,94 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
for (var e = [], r = 0; r < 256; ++r) e.push("%" + ((r < 16 ? "0" : "") + r.toString(16)).toUpperCase());
|
|
13
|
-
return e
|
|
14
|
-
}(),
|
|
15
|
-
compactQueue = function(e) {
|
|
16
|
-
for (; e.length;) {
|
|
17
|
-
var r = e.pop(),
|
|
18
|
-
t = r.obj[r.prop];
|
|
19
|
-
if (Array.isArray(t)) {
|
|
20
|
-
for (var o = [], n = 0; n < t.length; ++n) void 0 !== t[n] && o.push(t[n]);
|
|
21
|
-
r.obj[r.prop] = o
|
|
22
|
-
}
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), has = Object.prototype.hasOwnProperty, hexTable = function() {
|
|
4
|
+
for (var e = [], r = 0; r < 256; ++r) e.push("%" + ((r < 16 ? "0" : "") + r.toString(16)).toUpperCase());
|
|
5
|
+
return e;
|
|
6
|
+
}(), compactQueue = function(e) {
|
|
7
|
+
for (var r; e.length; ) {
|
|
8
|
+
var t = e.pop();
|
|
9
|
+
if (r = t.obj[t.prop], Array.isArray(r)) {
|
|
10
|
+
for (var o = [], a = 0; a < r.length; ++a) void 0 !== r[a] && o.push(r[a]);
|
|
11
|
+
t.obj[t.prop] = o;
|
|
23
12
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
if ("object" !== _typeof(t)) return [t, n];
|
|
36
|
-
!c.plainObjects && !c.allowPrototypes && has.call(Object.prototype, n) || (t[n] = !0)
|
|
37
|
-
}
|
|
38
|
-
return t
|
|
13
|
+
}
|
|
14
|
+
return r;
|
|
15
|
+
}, arrayToObject = function(e, r) {
|
|
16
|
+
for (var t = r && r.plainObjects ? Object.create(null) : {}, o = 0; o < e.length; ++o) void 0 !== e[o] && (t[o] = e[o]);
|
|
17
|
+
return t;
|
|
18
|
+
}, merge = function e(r, t, o) {
|
|
19
|
+
if (!t) return r;
|
|
20
|
+
if ("object" !== (0, _typeof2.default)(t)) {
|
|
21
|
+
if (Array.isArray(r)) r.push(t); else {
|
|
22
|
+
if ("object" !== (0, _typeof2.default)(r)) return [ r, t ];
|
|
23
|
+
(o.plainObjects || o.allowPrototypes || !has.call(Object.prototype, t)) && (r[t] = !0);
|
|
39
24
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
isBuffer = function(e) {
|
|
90
|
-
return null != e && !!(e.constructor && e.constructor.isBuffer && e.constructor.isBuffer(e))
|
|
91
|
-
};
|
|
25
|
+
return r;
|
|
26
|
+
}
|
|
27
|
+
if ("object" !== (0, _typeof2.default)(r)) return [ r ].concat(t);
|
|
28
|
+
var a = r;
|
|
29
|
+
return Array.isArray(r) && !Array.isArray(t) && (a = arrayToObject(r, o)), Array.isArray(r) && Array.isArray(t) ? (t.forEach((function(t, a) {
|
|
30
|
+
has.call(r, a) ? r[a] && "object" === (0, _typeof2.default)(r[a]) ? r[a] = e(r[a], t, o) : r.push(t) : r[a] = t;
|
|
31
|
+
})), r) : Object.keys(t).reduce((function(r, a) {
|
|
32
|
+
var n = t[a];
|
|
33
|
+
return has.call(r, a) ? r[a] = e(r[a], n, o) : r[a] = n, r;
|
|
34
|
+
}), a);
|
|
35
|
+
}, assign = function(e, r) {
|
|
36
|
+
return Object.keys(r).reduce((function(e, t) {
|
|
37
|
+
return e[t] = r[t], e;
|
|
38
|
+
}), e);
|
|
39
|
+
}, decode = function(e) {
|
|
40
|
+
try {
|
|
41
|
+
return decodeURIComponent(e.replace(/\+/g, " "));
|
|
42
|
+
} catch (r) {
|
|
43
|
+
return e;
|
|
44
|
+
}
|
|
45
|
+
}, encode = function(e) {
|
|
46
|
+
if (0 === e.length) return e;
|
|
47
|
+
for (var r = "string" == typeof e ? e : String(e), t = "", o = 0; o < r.length; ++o) {
|
|
48
|
+
var a = r.charCodeAt(o);
|
|
49
|
+
45 === a || 46 === a || 95 === a || 126 === a || a >= 48 && a <= 57 || a >= 65 && a <= 90 || a >= 97 && a <= 122 ? t += r.charAt(o) : a < 128 ? t += hexTable[a] : a < 2048 ? t += hexTable[192 | a >> 6] + hexTable[128 | 63 & a] : a < 55296 || a >= 57344 ? t += hexTable[224 | a >> 12] + hexTable[128 | a >> 6 & 63] + hexTable[128 | 63 & a] : (o += 1,
|
|
50
|
+
a = 65536 + ((1023 & a) << 10 | 1023 & r.charCodeAt(o)), t += hexTable[240 | a >> 18] + hexTable[128 | a >> 12 & 63] + hexTable[128 | a >> 6 & 63] + hexTable[128 | 63 & a]);
|
|
51
|
+
}
|
|
52
|
+
return t;
|
|
53
|
+
}, compact = function(e) {
|
|
54
|
+
for (var r = [ {
|
|
55
|
+
obj: {
|
|
56
|
+
o: e
|
|
57
|
+
},
|
|
58
|
+
prop: "o"
|
|
59
|
+
} ], t = [], o = 0; o < r.length; ++o) for (var a = r[o], n = a.obj[a.prop], c = Object.keys(n), u = 0; u < c.length; ++u) {
|
|
60
|
+
var i = c[u], f = n[i];
|
|
61
|
+
"object" === (0, _typeof2.default)(f) && null !== f && -1 === t.indexOf(f) && (r.push({
|
|
62
|
+
obj: n,
|
|
63
|
+
prop: i
|
|
64
|
+
}), t.push(f));
|
|
65
|
+
}
|
|
66
|
+
return compactQueue(r);
|
|
67
|
+
}, isRegExp = function(e) {
|
|
68
|
+
return "[object RegExp]" === Object.prototype.toString.call(e);
|
|
69
|
+
}, isBuffer = function(e) {
|
|
70
|
+
return null != e && !!(e.constructor && e.constructor.isBuffer && e.constructor.isBuffer(e));
|
|
71
|
+
};
|
|
72
|
+
|
|
92
73
|
module.exports = {
|
|
93
74
|
arrayToObject: arrayToObject,
|
|
94
75
|
assign: assign,
|
|
@@ -98,4 +79,4 @@ module.exports = {
|
|
|
98
79
|
isBuffer: isBuffer,
|
|
99
80
|
isRegExp: isRegExp,
|
|
100
81
|
merge: merge
|
|
101
|
-
};
|
|
82
|
+
};
|
package/lib/random.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function randomInt(n, r) {
|
|
4
|
-
return null == r && (r = n, n = 0), n + Math.floor(Math.random() * (r - n + 1))
|
|
4
|
+
return null == r && (r = n, n = 0), n + Math.floor(Math.random() * (r - n + 1));
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function random(n) {
|
|
8
|
-
n
|
|
8
|
+
n || (n = 6);
|
|
9
9
|
for (var r = "", o = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", t = o.length, a = 0; a < n; a++) r += o.charAt(randomInt(0, t - 1));
|
|
10
|
-
return r
|
|
10
|
+
return r;
|
|
11
11
|
}
|
|
12
|
+
|
|
12
13
|
module.exports = {
|
|
13
14
|
random: random,
|
|
14
15
|
randomInt: randomInt
|
|
15
|
-
};
|
|
16
|
+
};
|
package/lib/shallowEqual.js
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (var l = Object.prototype.hasOwnProperty.bind(e), f = 0; f < n.length; f++) {
|
|
28
|
-
var y = n[f];
|
|
29
|
-
if (!l(y)) return !1;
|
|
30
|
-
var c, i = t[y],
|
|
31
|
-
p = e[y];
|
|
32
|
-
if ((!1 === (c = o ? o.call(r, i, p, y) : void 0) || void 0 === c) && i !== p) return !1
|
|
33
|
-
}
|
|
34
|
-
return !0
|
|
35
|
-
};
|
|
36
|
-
module.exports = shallowEqual, module.exports.customEqual = customEqual;
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), shallowEqual = function(e, t) {
|
|
4
|
+
if (e === t) return !0;
|
|
5
|
+
if ("object" !== (0, _typeof2.default)(e) || null === e || "object" !== (0, _typeof2.default)(t) || null === t) return !1;
|
|
6
|
+
var r = Object.keys(e), u = Object.keys(t);
|
|
7
|
+
if (r.length !== u.length) return !1;
|
|
8
|
+
for (var l = Object.prototype.hasOwnProperty.bind(t), o = 0; o < r.length; o++) if (!l(r[o]) || e[r[o]] !== t[r[o]]) return !1;
|
|
9
|
+
return !0;
|
|
10
|
+
}, customEqual = function(e, t, r, u) {
|
|
11
|
+
var l = r ? r.call(u, e, t) : void 0;
|
|
12
|
+
if (void 0 !== l) return !!l;
|
|
13
|
+
if (e === t) return !0;
|
|
14
|
+
if ("object" !== (0, _typeof2.default)(e) || !e || "object" !== (0, _typeof2.default)(t) || !t) return !1;
|
|
15
|
+
var o = Object.keys(e), n = Object.keys(t);
|
|
16
|
+
if (o.length !== n.length) return !1;
|
|
17
|
+
for (var i = Object.prototype.hasOwnProperty.bind(t), a = 0; a < o.length; a++) {
|
|
18
|
+
var f = o[a];
|
|
19
|
+
if (!i(f)) return !1;
|
|
20
|
+
var p = e[f], c = t[f];
|
|
21
|
+
if ((!1 === (l = r ? r.call(u, p, c, f) : void 0) || void 0 === l) && p !== c) return !1;
|
|
22
|
+
}
|
|
23
|
+
return !0;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = shallowEqual, module.exports.customEqual = customEqual;
|
package/lib/store.js
CHANGED
|
@@ -1,103 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
|
|
3
|
+
var _Base64 = require("./encrypt/_base64"), trim = require("./_trim"), Global = "undefined" != typeof window ? window : global, doc = Global.document, _localStorage = {
|
|
4
|
+
localStorage: Global.localStorage,
|
|
5
|
+
read: function(e) {
|
|
6
|
+
return _localStorage.localStorage.getItem(e);
|
|
7
|
+
},
|
|
8
|
+
write: function(e, o) {
|
|
9
|
+
return _localStorage.localStorage.setItem(e, o);
|
|
10
|
+
},
|
|
11
|
+
each: function(e) {
|
|
12
|
+
for (var o = _localStorage.localStorage.length - 1; o >= 0; o--) {
|
|
13
|
+
var r = _localStorage.localStorage.key(o);
|
|
14
|
+
e(_localStorage.read(r), r);
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
remove: function(e) {
|
|
18
|
+
return _localStorage.localStorage.removeItem(e);
|
|
19
|
+
},
|
|
20
|
+
clearAll: function() {
|
|
21
|
+
return _localStorage.localStorage.clear();
|
|
22
|
+
}
|
|
23
|
+
}, _sessionStorage = {
|
|
24
|
+
sessionStorage: Global.sessionStorage,
|
|
25
|
+
read: function(e) {
|
|
26
|
+
return _sessionStorage.sessionStorage.getItem(e);
|
|
27
|
+
},
|
|
28
|
+
write: function(e, o) {
|
|
29
|
+
return _sessionStorage.sessionStorage.setItem(e, o);
|
|
30
|
+
},
|
|
31
|
+
each: function(e) {
|
|
32
|
+
for (var o = _sessionStorage.sessionStorage.length - 1; o >= 0; o--) {
|
|
33
|
+
var r = _sessionStorage.sessionStorage.key(o);
|
|
34
|
+
e(_sessionStorage.read(r), r);
|
|
25
35
|
}
|
|
26
36
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
remove: function(e) {
|
|
38
|
+
return _sessionStorage.sessionStorage.removeItem(e);
|
|
39
|
+
},
|
|
40
|
+
clearAll: function() {
|
|
41
|
+
return _sessionStorage.sessionStorage.clear();
|
|
42
|
+
}
|
|
43
|
+
}, Store = {
|
|
44
|
+
encrypt: function(e) {
|
|
45
|
+
var o = (new _Base64).encode(e);
|
|
46
|
+
return o;
|
|
47
|
+
},
|
|
48
|
+
decrypt: function(e) {
|
|
49
|
+
var o = (new _Base64).decode(e);
|
|
50
|
+
return o = escape(o), o = o.replace(/%00/g, ""), o = unescape(o), o;
|
|
51
|
+
},
|
|
52
|
+
setCookieByDays: function(e, o) {
|
|
53
|
+
var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1, t = e + "=" + escape(o);
|
|
54
|
+
if ("number" == typeof r) {
|
|
55
|
+
var a = new Date;
|
|
56
|
+
a.setTime(a.getTime() + 24 * r * 60 * 60 * 1e3), t += "; expires=" + a.toUTCString();
|
|
57
|
+
}
|
|
58
|
+
doc.cookie = t;
|
|
59
|
+
},
|
|
60
|
+
getAllCookies: function() {
|
|
61
|
+
var e = {}, o = doc.cookie;
|
|
62
|
+
if ("" === o) return e;
|
|
63
|
+
for (var r = o.split("; "), t = 0; t < r.length; t++) {
|
|
64
|
+
var a = r[t], n = a.indexOf("="), s = a.substring(0, n), i = a.substring(n + 1);
|
|
65
|
+
i = JSON.parse(unescape(i)), e[s] = i;
|
|
66
|
+
}
|
|
67
|
+
return e;
|
|
68
|
+
},
|
|
69
|
+
setCookieByHour: function(e, o, r) {
|
|
70
|
+
var t = new Date;
|
|
71
|
+
t.setTime(t.getTime() + 60 * r * 60 * 1e3), doc.cookie = e + "=" + escape(o) + ";expires=" + t.toGMTString();
|
|
72
|
+
},
|
|
73
|
+
getCookieByName: function(e) {
|
|
74
|
+
var o = doc.cookie.match(new RegExp("(^| )" + e + "=([^;]*)(;|$)"));
|
|
75
|
+
return null != o ? unescape(o[2]) : null;
|
|
76
|
+
},
|
|
77
|
+
removeCookieByName: function(e) {
|
|
78
|
+
e && Store._has(e) && (doc.cookie = escape(e) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/");
|
|
79
|
+
},
|
|
80
|
+
clearAllCookie: function() {
|
|
81
|
+
Store._each((function(e, o) {
|
|
82
|
+
Store.removeCookieByName(o);
|
|
83
|
+
}));
|
|
84
|
+
},
|
|
85
|
+
_has: function(e) {
|
|
86
|
+
return new RegExp("(?:^|;\\s*)" + escape(e).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=").test(doc.cookie);
|
|
87
|
+
},
|
|
88
|
+
_each: function(e) {
|
|
89
|
+
for (var o = doc.cookie.split(/; ?/g), r = o.length - 1; r >= 0; r--) if (trim(o[r])) {
|
|
90
|
+
var t = o[r].split("="), a = unescape(t[0]);
|
|
91
|
+
e(unescape(t[1]), a);
|
|
46
92
|
}
|
|
47
93
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
decrypt: function(e) {
|
|
54
|
-
var o = (new _Base64).decode(e);
|
|
55
|
-
return o = escape(o), o = o.replace(/%00/g, ""), o = unescape(o), o
|
|
56
|
-
},
|
|
57
|
-
setCookieByDays: function(e, o, r) {
|
|
58
|
-
var t, a = 2 < arguments.length && void 0 !== r ? r : 1,
|
|
59
|
-
n = e + "=" + escape(o);
|
|
60
|
-
"number" == typeof a && ((t = new Date).setTime(t.getTime() + 24 * a * 60 * 60 * 1e3), n += "; expires=" + t.toUTCString()), doc.cookie = n
|
|
61
|
-
},
|
|
62
|
-
getAllCookies: function() {
|
|
63
|
-
var e = {},
|
|
64
|
-
o = doc.cookie;
|
|
65
|
-
if ("" === o) return e;
|
|
66
|
-
for (var r = o.split("; "), t = 0; t < r.length; t++) {
|
|
67
|
-
var a = r[t],
|
|
68
|
-
n = a.indexOf("="),
|
|
69
|
-
s = a.substring(0, n),
|
|
70
|
-
c = a.substring(n + 1),
|
|
71
|
-
c = JSON.parse(unescape(c));
|
|
72
|
-
e[s] = c
|
|
73
|
-
}
|
|
74
|
-
return e
|
|
75
|
-
},
|
|
76
|
-
setCookieByHour: function(e, o, r) {
|
|
77
|
-
var t = new Date;
|
|
78
|
-
t.setTime(t.getTime() + 60 * r * 60 * 1e3), doc.cookie = e + "=" + escape(o) + ";expires=" + t.toGMTString()
|
|
79
|
-
},
|
|
80
|
-
getCookieByName: function(e) {
|
|
81
|
-
var o = doc.cookie.match(new RegExp("(^| )" + e + "=([^;]*)(;|$)"));
|
|
82
|
-
return null != o ? unescape(o[2]) : null
|
|
83
|
-
},
|
|
84
|
-
removeCookieByName: function(e) {
|
|
85
|
-
e && Store._has(e) && (doc.cookie = escape(e) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")
|
|
86
|
-
},
|
|
87
|
-
clearAllCookie: function() {
|
|
88
|
-
Store._each(function(e, o) {
|
|
89
|
-
Store.removeCookieByName(o)
|
|
90
|
-
})
|
|
91
|
-
},
|
|
92
|
-
_has: function(e) {
|
|
93
|
-
return new RegExp("(?:^|;\\s*)" + escape(e).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=").test(doc.cookie)
|
|
94
|
-
},
|
|
95
|
-
_each: function(e) {
|
|
96
|
-
for (var o, r, t = doc.cookie.split(/; ?/g), a = t.length - 1; 0 <= a; a--) {
|
|
97
|
-
trim(t[a]) && (o = t[a].split("="), r = unescape(o[0]), e(unescape(o[1]), r))
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
lsTool: _localStorage,
|
|
101
|
-
session: _sessionStorage
|
|
102
|
-
};
|
|
103
|
-
module.exports = Store;
|
|
94
|
+
lsTool: _localStorage,
|
|
95
|
+
session: _sessionStorage
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
module.exports = Store;
|
package/lib/strUtils.js
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
var deepCopy = require("./_deepCopy"), utils = require("./utils");
|
|
4
|
+
|
|
4
5
|
module.exports = {
|
|
5
6
|
toCapitalStr: function(e) {
|
|
6
|
-
return
|
|
7
|
+
return utils.isNil(e) ? e : utils.isString(e) ? e[0].toUpperCase() + e.slice(1, e.length) : e;
|
|
7
8
|
},
|
|
8
9
|
camelCase: function(e) {
|
|
9
|
-
return e.charAt(0).toUpperCase() + e.slice(1).replace(/-(\w)/g, function(e, r) {
|
|
10
|
-
return r.toUpperCase()
|
|
11
|
-
})
|
|
10
|
+
return e.charAt(0).toUpperCase() + e.slice(1).replace(/-(\w)/g, (function(e, r) {
|
|
11
|
+
return r.toUpperCase();
|
|
12
|
+
}));
|
|
12
13
|
},
|
|
13
14
|
transCamel: function(e) {
|
|
14
|
-
return (e = e.toLowerCase()).replace(/-(\w)/g, function(e, r) {
|
|
15
|
-
return r.toUpperCase()
|
|
16
|
-
})
|
|
15
|
+
return (e = e.toLowerCase()).replace(/-(\w)/g, (function(e, r) {
|
|
16
|
+
return r.toUpperCase();
|
|
17
|
+
}));
|
|
17
18
|
},
|
|
18
19
|
capFirst: function(e) {
|
|
19
|
-
return e && "" !== e ? e.replace(/(\w)/, function(e) {
|
|
20
|
-
return e.toUpperCase()
|
|
21
|
-
}) : e
|
|
20
|
+
return e && "" !== e ? e.replace(/(\w)/, (function(e) {
|
|
21
|
+
return e.toUpperCase();
|
|
22
|
+
})) : e;
|
|
22
23
|
},
|
|
23
24
|
hashCode: function(e) {
|
|
24
25
|
if (e) {
|
|
25
26
|
e = e.toString();
|
|
26
|
-
for (var r = 0, t = 0; t < e.length; t++) r = 31 * r + e.charCodeAt(t), r =
|
|
27
|
-
return r
|
|
27
|
+
for (var r = 0, t = 0; t < e.length; t++) r = 31 * r + e.charCodeAt(t), r = (n = r) > 2147483647 || n < -2147483648 ? 4294967295 & n : n;
|
|
28
|
+
return r;
|
|
28
29
|
}
|
|
29
30
|
var n;
|
|
30
|
-
return null
|
|
31
|
+
return null;
|
|
31
32
|
},
|
|
32
33
|
dealScaleAndUnit: function(e, r) {
|
|
33
|
-
var t =
|
|
34
|
+
var t = deepCopy.clone(r);
|
|
35
|
+
if (t || (t = {
|
|
34
36
|
selfenable: !1,
|
|
35
37
|
fixnumber: 2,
|
|
36
38
|
thousandsplitchar: !0
|
|
37
|
-
};
|
|
38
|
-
if (!utils.isFloat(e)) return e;
|
|
39
|
+
}), !utils.isFloat(e)) return e;
|
|
39
40
|
var n = "";
|
|
40
|
-
"-" == (e = e.toString()).charAt(0) && (n = "-", e = e.substring(1, e.length)),
|
|
41
|
+
"-" == (e = e.toString()).charAt(0) && (n = "-", e = e.substring(1, e.length)),
|
|
42
|
+
null != t.selfscale && "" != t.selfscale || null != t.selfunit && "" != t.selfunit || (t.selfscale = "1000,1000,1000",
|
|
43
|
+
t.selfunit = "K,M,B");
|
|
41
44
|
var l = 2;
|
|
42
45
|
null != t.fixnumber && "NaN" != parseInt(t.fixnumber).toString() && (l = parseInt(t.fixnumber));
|
|
43
46
|
var a = "";
|
|
@@ -45,31 +48,37 @@ module.exports = {
|
|
|
45
48
|
var i = t.selfunit;
|
|
46
49
|
null == i && (i = "");
|
|
47
50
|
var s = t.selfscale;
|
|
48
|
-
if (null == s || "" == s.toString().trim()) a = i + a;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
if (null == s || "" == s.toString().trim()) a = i + a; else {
|
|
52
|
+
for (var o = i.split(","), u = s.split(","), f = [], p = !0, c = 0; c < u.length; c++) if (null != u[c] && "NaN" != parseFloat(u[c]).toString()) {
|
|
53
|
+
if ("NaN" == parseFloat(u[c]).toString() || "0" == parseFloat(u[c]).toString() || parseFloat(u[c]) < 0) {
|
|
54
|
+
p = !1;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
0 == f.length ? f[0] = u[c] : f[f.length] = parseFloat(u[c]) * parseFloat(f[f.length - 1]);
|
|
58
|
+
}
|
|
59
|
+
if (u = f, p) for (var h = u.length - 1; h >= 0; h--) if (!(h > o.length - 1)) {
|
|
60
|
+
null == o[h] && (o[h] = "");
|
|
61
|
+
var g = parseFloat(e) / u[h];
|
|
62
|
+
if (e.indexOf(".") > -1) {
|
|
63
|
+
var d = e.substr(e.indexOf(".") + 1, e.length).length;
|
|
64
|
+
g = parseFloat(e) * Math.pow(10, d) / (u[h] * Math.pow(10, d));
|
|
65
|
+
}
|
|
66
|
+
if (Math.abs(g) >= 1) {
|
|
67
|
+
e = g, a = o[h] + a;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
|
-
return -1
|
|
73
|
+
return l > -1 && (e = parseFloat(e).toFixed(l) + ""), t.fillzero || (e = parseFloat(e) + ""),
|
|
74
|
+
(null == t.thousandsplitchar || t.thousandsplitchar) && (e = e.indexOf(".") > -1 ? e.substr(0, e.indexOf(".")).replace(/\d{1,3}(?=(\d{3})+$)/g, "$&,") + e.substr(e.indexOf("."), e.length) : e.replace(/\d{1,3}(?=(\d{3})+$)/g, "$&,")),
|
|
75
|
+
e = n + e, null != t.prefix && (e = t.prefix + e), e += a;
|
|
70
76
|
},
|
|
71
77
|
toUTF8: function(e) {
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
var r, t, n, l = "";
|
|
79
|
+
for (t = e.length, r = 0; r < t; r++) (n = e.charCodeAt(r)) >= 1 && n <= 127 ? l += e.charAt(r) : n > 2047 ? (l += String.fromCharCode(224 | n >> 12 & 15),
|
|
80
|
+
l += String.fromCharCode(128 | n >> 6 & 63), l += String.fromCharCode(128 | n >> 0 & 63)) : (l += String.fromCharCode(192 | n >> 6 & 31),
|
|
81
|
+
l += String.fromCharCode(128 | n >> 0 & 63));
|
|
82
|
+
return l;
|
|
74
83
|
}
|
|
75
|
-
};
|
|
84
|
+
};
|