amos-tool 1.4.6 → 1.4.9
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 +5 -0
- package/apis/objectPath.md +129 -129
- package/index.d.ts +23 -4
- 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 +8 -7
- 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 +14 -64
- 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 +22 -25
- package/lib/math/_keyColor.js +3 -1
- 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 +78 -86
- 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 +168 -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/utils.js
CHANGED
|
@@ -1,260 +1,204 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return
|
|
5
|
-
return
|
|
6
|
-
} : function(e) {
|
|
7
|
-
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
8
|
-
})(e)
|
|
9
|
-
}
|
|
10
|
-
var _typeOfList = require("./_typeOfList"),
|
|
11
|
-
ObjProto = Object.prototype,
|
|
12
|
-
toString = ObjProto.toString,
|
|
13
|
-
hasOwnProperty = ObjProto.hasOwnProperty,
|
|
14
|
-
nativeIsArray = Array.isArray,
|
|
15
|
-
nativeKeys = Object.keys,
|
|
16
|
-
BUILTIN_OBJECT = _typeOfList.BUILTIN_OBJECT,
|
|
17
|
-
TYPED_ARRAY = _typeOfList.TYPED_ARRAY,
|
|
18
|
-
property = function(t) {
|
|
19
|
-
return function(e) {
|
|
20
|
-
return null == e ? void 0 : e[t]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
MAX_ARRAY_INDEX = Math.pow(2, 53) - 1,
|
|
24
|
-
getLength = property("length"),
|
|
25
|
-
isArrayLike = function(e) {
|
|
26
|
-
var t = getLength(e);
|
|
27
|
-
return "number" == typeof t && 0 <= t && t <= MAX_ARRAY_INDEX
|
|
28
|
-
},
|
|
29
|
-
isNumber = function(e) {
|
|
30
|
-
var t = /^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/.test(e),
|
|
31
|
-
n = "number" == typeof e && !isNaN(e);
|
|
32
|
-
return t || n
|
|
33
|
-
},
|
|
34
|
-
isFloat = function(e) {
|
|
35
|
-
return /^-?\d+(\.\d+)?$/.test(e)
|
|
36
|
-
},
|
|
37
|
-
isOpacity = function(e) {
|
|
38
|
-
return /^-?\d+(\.\d+)?$/.test(e)
|
|
39
|
-
},
|
|
40
|
-
toFloat = function(e) {
|
|
41
|
-
return isNumber(e) ? Number(e) : Number(0)
|
|
42
|
-
},
|
|
43
|
-
isString = function(e) {
|
|
44
|
-
return "[object String]" === toString.call(e)
|
|
45
|
-
},
|
|
46
|
-
isArray = nativeIsArray || function(e) {
|
|
47
|
-
return "[object Array]" === toString.call(e)
|
|
48
|
-
},
|
|
49
|
-
isArguments = function(e) {
|
|
50
|
-
return "[object Arguments]" === toString.call(e)
|
|
51
|
-
},
|
|
52
|
-
isObject = function(e) {
|
|
53
|
-
var t = _typeof(e);
|
|
54
|
-
return "function" === t || "object" === t && !!e
|
|
55
|
-
},
|
|
56
|
-
isBoolean = function(e) {
|
|
57
|
-
return !0 === e || !1 === e || "[object Boolean]" === toString.call(e)
|
|
58
|
-
},
|
|
59
|
-
isFunction = function(e) {
|
|
60
|
-
return "[object Function]" === toString.call(e)
|
|
61
|
-
},
|
|
62
|
-
isNull = function(e) {
|
|
63
|
-
return null === e
|
|
64
|
-
},
|
|
65
|
-
isUndefined = function(e) {
|
|
66
|
-
return void 0 === e
|
|
67
|
-
},
|
|
68
|
-
isNil = function(e) {
|
|
69
|
-
return null == e
|
|
70
|
-
},
|
|
71
|
-
isEmptyObject = function(e) {
|
|
72
|
-
if (e)
|
|
73
|
-
for (var t in e)
|
|
74
|
-
if (hasOwnProperty.call(e, t)) return !1;
|
|
75
|
-
return !0
|
|
76
|
-
},
|
|
77
|
-
has = function(e, t) {
|
|
78
|
-
if (!isArray(t)) return null != e && Object.prototype.hasOwnProperty.call(e, t);
|
|
79
|
-
for (var n = t.length, r = 0; r < n; r++) {
|
|
80
|
-
var i = t[r];
|
|
81
|
-
if (null == e || !Object.prototype.hasOwnProperty.call(e, i)) return !1;
|
|
82
|
-
e = e[i]
|
|
83
|
-
}
|
|
84
|
-
return !!n
|
|
85
|
-
},
|
|
86
|
-
keys = function(e) {
|
|
87
|
-
if (!isObject(e)) return [];
|
|
88
|
-
if (nativeKeys) return nativeKeys(e);
|
|
89
|
-
var t = [];
|
|
90
|
-
for (var n in e) has(e, n) && t.push(n);
|
|
91
|
-
return t
|
|
92
|
-
},
|
|
93
|
-
values = function(e) {
|
|
94
|
-
for (var t = keys(e), n = t.length, r = Array(n), i = 0; i < n; i++) r[i] = e[t[i]];
|
|
95
|
-
return r
|
|
96
|
-
},
|
|
97
|
-
noop = function() {},
|
|
98
|
-
isEmpty = function(e) {
|
|
99
|
-
return null == e || (isArrayLike(e) && (isArray(e) || isString(e) || isArguments(e)) ? 0 === e.length : 0 === keys(e).length)
|
|
100
|
-
},
|
|
101
|
-
isElement = function(e) {
|
|
102
|
-
return !(!e || 1 !== e.nodeType)
|
|
103
|
-
},
|
|
104
|
-
isHTMLElement = function(e) {
|
|
105
|
-
return window.HTMLElement || window.Element ? e instanceof(window.HTMLElement || window.Element) : e && "object" === ("undefined" == typeof n ? "undefined" : _typeof(n)) && 1 === e.nodeType && "string" == typeof e.nodeName
|
|
106
|
-
},
|
|
107
|
-
isSVGElement = function(e) {
|
|
108
|
-
return window.SVGElement && e instanceof window.SVGElement
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), _typeOfList = require("./_typeOfList"), 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(e) {
|
|
4
|
+
return function(t) {
|
|
5
|
+
return null == t ? void 0 : t[e];
|
|
109
6
|
};
|
|
7
|
+
}, MAX_ARRAY_INDEX = Math.pow(2, 53) - 1, getLength = property("length"), isArrayLike = function(e) {
|
|
8
|
+
var t = getLength(e);
|
|
9
|
+
return "number" == typeof t && t >= 0 && t <= MAX_ARRAY_INDEX;
|
|
10
|
+
}, isNumber = function(e) {
|
|
11
|
+
var t = /^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/.test(e), n = "number" == typeof e && !isNaN(e);
|
|
12
|
+
return t || n;
|
|
13
|
+
}, isFloat = function(e) {
|
|
14
|
+
return /^-?\d+(\.\d+)?$/.test(e);
|
|
15
|
+
}, isOpacity = function(e) {
|
|
16
|
+
return /^-?\d+(\.\d+)?$/.test(e);
|
|
17
|
+
}, toFloat = function(e) {
|
|
18
|
+
return isNumber(e) ? Number(e) : Number(0);
|
|
19
|
+
}, isString = function(e) {
|
|
20
|
+
return "[object String]" === toString.call(e);
|
|
21
|
+
}, isArray = nativeIsArray || function(e) {
|
|
22
|
+
return "[object Array]" === toString.call(e);
|
|
23
|
+
}, isArguments = function(e) {
|
|
24
|
+
return "[object Arguments]" === toString.call(e);
|
|
25
|
+
}, isObject = function(e) {
|
|
26
|
+
var t = (0, _typeof2.default)(e);
|
|
27
|
+
return "function" === t || "object" === t && !!e;
|
|
28
|
+
}, isOnlyObject = function(e) {
|
|
29
|
+
return "object" === (0, _typeof2.default)(e) && "[object Object]" === toString.call(e) && !!e;
|
|
30
|
+
}, isBoolean = function(e) {
|
|
31
|
+
return !0 === e || !1 === e || "[object Boolean]" === toString.call(e);
|
|
32
|
+
}, isFunction = function(e) {
|
|
33
|
+
return "[object Function]" === toString.call(e);
|
|
34
|
+
}, isNull = function(e) {
|
|
35
|
+
return null === e;
|
|
36
|
+
}, isUndefined = function(e) {
|
|
37
|
+
return void 0 === e;
|
|
38
|
+
}, isNil = function(e) {
|
|
39
|
+
return null == e;
|
|
40
|
+
}, isEmptyObject = function(e) {
|
|
41
|
+
if (e) for (var t in e) if (hasOwnProperty.call(e, t)) return !1;
|
|
42
|
+
return !0;
|
|
43
|
+
}, has = function(e, t) {
|
|
44
|
+
if (!isArray(t)) return null != e && Object.prototype.hasOwnProperty.call(e, t);
|
|
45
|
+
for (var n = t.length, r = 0; r < n; r++) {
|
|
46
|
+
var i = t[r];
|
|
47
|
+
if (null == e || !Object.prototype.hasOwnProperty.call(e, i)) return !1;
|
|
48
|
+
e = e[i];
|
|
49
|
+
}
|
|
50
|
+
return !!n;
|
|
51
|
+
}, keys = function(e) {
|
|
52
|
+
if (!isObject(e)) return [];
|
|
53
|
+
if (nativeKeys) return nativeKeys(e);
|
|
54
|
+
var t = [];
|
|
55
|
+
for (var n in e) has(e, n) && t.push(n);
|
|
56
|
+
return t;
|
|
57
|
+
}, values = function(e) {
|
|
58
|
+
for (var t = keys(e), n = t.length, r = Array(n), i = 0; i < n; i++) r[i] = e[t[i]];
|
|
59
|
+
return r;
|
|
60
|
+
}, noop = function() {}, isEmpty = function(e) {
|
|
61
|
+
return null == e || (isArrayLike(e) && (isArray(e) || isString(e) || isArguments(e)) ? 0 === e.length : 0 === keys(e).length);
|
|
62
|
+
}, isElement = function(e) {
|
|
63
|
+
return !(!e || 1 !== e.nodeType);
|
|
64
|
+
}, isHTMLElement = function(e) {
|
|
65
|
+
return window.HTMLElement || window.Element ? e instanceof (window.HTMLElement || window.Element) : e && "object" === ("undefined" == typeof n ? "undefined" : (0,
|
|
66
|
+
_typeof2.default)(n)) && 1 === e.nodeType && "string" == typeof e.nodeName;
|
|
67
|
+
}, isSVGElement = function(e) {
|
|
68
|
+
return window.SVGElement && e instanceof window.SVGElement;
|
|
69
|
+
};
|
|
110
70
|
|
|
111
71
|
function isDom(e) {
|
|
112
|
-
return "object" ===
|
|
72
|
+
return "object" === (0, _typeof2.default)(e) && "number" == typeof e.nodeType && "object" === (0,
|
|
73
|
+
_typeof2.default)(e.ownerDocument);
|
|
113
74
|
}
|
|
114
75
|
|
|
115
76
|
function isUrl(e) {
|
|
116
|
-
return isString(e) && (/^https?:\/\/(?!\-)(?:(([0-9]{1,3}\.){3}[0-9]{1,3}))(:[0-9]{1,4}\/)?/.test(e) || /^https?:\/\/(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}/.test(e))
|
|
77
|
+
return isString(e) && (/^https?:\/\/(?!\-)(?:(([0-9]{1,3}\.){3}[0-9]{1,3}))(:[0-9]{1,4}\/)?/.test(e) || /^https?:\/\/(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}/.test(e));
|
|
117
78
|
}
|
|
118
79
|
|
|
119
80
|
function isBuiltInObject(e) {
|
|
120
|
-
return !!BUILTIN_OBJECT[toString.call(e)]
|
|
81
|
+
return !!BUILTIN_OBJECT[toString.call(e)];
|
|
121
82
|
}
|
|
83
|
+
|
|
122
84
|
var null2default = function(e) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
},
|
|
150
|
-
isImageSrc = function() {
|
|
151
|
-
var t = /data:image\/(jpe?g|png|gif|bmp|ico|tga);base64,/i,
|
|
152
|
-
n = /.(jpe?g|png|gif|bmp|ico|tga)(\?.*)?$/i;
|
|
153
|
-
return function(e) {
|
|
154
|
-
return t.test(e) || n.test(e)
|
|
155
|
-
}
|
|
156
|
-
}(),
|
|
157
|
-
encodeNumber = function(e, t, n, r) {
|
|
158
|
-
var i = 1 < arguments.length && void 0 !== t ? t : 3,
|
|
159
|
-
o = 2 < arguments.length && void 0 !== n ? n : 4,
|
|
160
|
-
s = 3 < arguments.length && void 0 !== r ? r : "*",
|
|
161
|
-
u = String(e),
|
|
162
|
-
l = i + o,
|
|
163
|
-
c = s.repeat(o);
|
|
164
|
-
return u.length > l ? u.substr(0, i) + c + u.substr(l) : u.substr(0, i) + c
|
|
165
|
-
},
|
|
166
|
-
getFileExtension = function(e) {
|
|
167
|
-
if (e) {
|
|
168
|
-
var t = e.lastIndexOf(".");
|
|
169
|
-
return 0 < t ? e.substring(t + 1) : ""
|
|
170
|
-
}
|
|
171
|
-
return ""
|
|
172
|
-
},
|
|
173
|
-
some = function(e, t, n) {
|
|
174
|
-
if (null == e) throw new TypeError;
|
|
175
|
-
var r = Object(e),
|
|
176
|
-
i = r.length >>> 0;
|
|
177
|
-
if ("function" != typeof t) throw new TypeError;
|
|
178
|
-
for (var o = 3 <= arguments.length ? n : void 0, s = 0; s < i; s++)
|
|
179
|
-
if (s in r && t.call(o, r[s], s, r)) return !0;
|
|
180
|
-
return !1
|
|
181
|
-
},
|
|
182
|
-
every = function(e, t, n) {
|
|
183
|
-
var r, i;
|
|
184
|
-
if (null == e) throw new TypeError("arr is null or not defined");
|
|
185
|
-
var o = Object(e),
|
|
186
|
-
s = o.length >>> 0;
|
|
187
|
-
if ("function" != typeof t) throw new TypeError;
|
|
188
|
-
for (2 < arguments.length && (r = n), i = 0; i < s;) {
|
|
189
|
-
if (i in o) {
|
|
190
|
-
var u = o[i];
|
|
191
|
-
if (!t.call(r, u, i, o)) return !1
|
|
192
|
-
}
|
|
193
|
-
i++
|
|
194
|
-
}
|
|
195
|
-
return !0
|
|
196
|
-
},
|
|
197
|
-
reduce = function(e, t, n) {
|
|
198
|
-
if (null === e) throw new TypeError("Array.prototype.reduce called on null or undefined");
|
|
199
|
-
if ("function" != typeof t) throw new TypeError(t + " is not a function");
|
|
200
|
-
var r, i = Object(e),
|
|
201
|
-
o = i.length >>> 0,
|
|
202
|
-
s = 0;
|
|
203
|
-
if (3 <= arguments.length) r = n;
|
|
204
|
-
else {
|
|
205
|
-
for (; s < o && !(s in i);) s++;
|
|
206
|
-
if (o <= s) throw new TypeError("Reduce of empty array with no initial value");
|
|
207
|
-
r = i[s++]
|
|
208
|
-
}
|
|
209
|
-
for (; s < o;) s in i && (r = t(r, i[s], s, i)), s++;
|
|
210
|
-
return r
|
|
211
|
-
},
|
|
212
|
-
parse2string = function(e) {
|
|
213
|
-
return isEmpty(e) ? "" : JSON.stringify(e)
|
|
214
|
-
},
|
|
215
|
-
parse2object = function(e) {
|
|
216
|
-
return isEmpty(e) ? null : JSON.parse(e)
|
|
217
|
-
},
|
|
218
|
-
dataToArray = function(e) {
|
|
219
|
-
return isArray(e) ? e : [e]
|
|
85
|
+
return isNull(e) || isUndefined(e) ? "" : e;
|
|
86
|
+
}, isJson = function(e) {
|
|
87
|
+
return "object" === (0, _typeof2.default)(e) && "[object object]" === toString.call(e).toLowerCase() && !e.length;
|
|
88
|
+
}, stringIsJson = function e(t) {
|
|
89
|
+
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) {
|
|
90
|
+
return e(t);
|
|
91
|
+
})).reduce((function(e, t) {
|
|
92
|
+
return !!t;
|
|
93
|
+
})));
|
|
94
|
+
}, isKeyInObject = function(e, t) {
|
|
95
|
+
isString(e) && (e = [ e ]);
|
|
96
|
+
var n = 0;
|
|
97
|
+
return e.forEach((function(e) {
|
|
98
|
+
e in t && n++;
|
|
99
|
+
})), e.length === n;
|
|
100
|
+
}, simpleEqual = function(e, t) {
|
|
101
|
+
if (e === t) return !0;
|
|
102
|
+
if ("object" !== (0, _typeof2.default)(e) || null === e || "object" !== (0, _typeof2.default)(t) || null === t) return !1;
|
|
103
|
+
var n = nativeKeys(e), r = nativeKeys(t);
|
|
104
|
+
if (n.length !== r.length) return !1;
|
|
105
|
+
for (var i = hasOwnProperty.bind(t), o = 0; o < n.length; o++) if (!i(n[o]) || e[n[o]] !== t[n[o]]) return !1;
|
|
106
|
+
return !0;
|
|
107
|
+
}, isImageSrc = function() {
|
|
108
|
+
var e = /data:image\/(jpe?g|png|gif|bmp|ico|tga|svg(\+xml)?);base64,/i, t = /.(jpe?g|png|gif|bmp|ico|tga|svg)(\?.*)?$/i;
|
|
109
|
+
return function(n) {
|
|
110
|
+
return e.test(n) || t.test(n);
|
|
220
111
|
};
|
|
112
|
+
}(), encodeNumber = function(e) {
|
|
113
|
+
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 3, n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 4, r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : "*", i = String(e), o = t + n, u = r.repeat(n);
|
|
114
|
+
return i.length > o ? i.substr(0, t) + u + i.substr(o) : i.substr(0, t) + u;
|
|
115
|
+
}, getFileExtension = function(e) {
|
|
116
|
+
if (e) {
|
|
117
|
+
var t = e.lastIndexOf(".");
|
|
118
|
+
return t > 0 ? e.substring(t + 1) : "";
|
|
119
|
+
}
|
|
120
|
+
return "";
|
|
121
|
+
}, some = function(e, t) {
|
|
122
|
+
if (null == e) throw new TypeError;
|
|
123
|
+
var n = Object(e), r = n.length >>> 0;
|
|
124
|
+
if ("function" != typeof t) throw new TypeError;
|
|
125
|
+
for (var i = arguments.length >= 3 ? arguments[2] : void 0, o = 0; o < r; o++) if (o in n && t.call(i, n[o], o, n)) return !0;
|
|
126
|
+
return !1;
|
|
127
|
+
}, every = function(e, t, n) {
|
|
128
|
+
var r, i;
|
|
129
|
+
if (null == e) throw new TypeError("arr is null or not defined");
|
|
130
|
+
var o = Object(e), u = o.length >>> 0;
|
|
131
|
+
if ("function" != typeof t) throw new TypeError;
|
|
132
|
+
for (arguments.length > 2 && (r = n), i = 0; i < u; ) {
|
|
133
|
+
var s;
|
|
134
|
+
if (i in o) {
|
|
135
|
+
s = o[i];
|
|
136
|
+
var l = t.call(r, s, i, o);
|
|
137
|
+
if (!l) return !1;
|
|
138
|
+
}
|
|
139
|
+
i++;
|
|
140
|
+
}
|
|
141
|
+
return !0;
|
|
142
|
+
}, reduce = function(e, t) {
|
|
143
|
+
if (null === e) throw new TypeError("Array.prototype.reduce called on null or undefined");
|
|
144
|
+
if ("function" != typeof t) throw new TypeError(t + " is not a function");
|
|
145
|
+
var n, r = Object(e), i = r.length >>> 0, o = 0;
|
|
146
|
+
if (arguments.length >= 3) n = arguments[2]; else {
|
|
147
|
+
for (;o < i && !(o in r); ) o++;
|
|
148
|
+
if (o >= i) throw new TypeError("Reduce of empty array with no initial value");
|
|
149
|
+
n = r[o++];
|
|
150
|
+
}
|
|
151
|
+
for (;o < i; ) o in r && (n = t(n, r[o], o, r)), o++;
|
|
152
|
+
return n;
|
|
153
|
+
}, parse2string = function(e) {
|
|
154
|
+
return isEmpty(e) ? "" : JSON.stringify(e);
|
|
155
|
+
}, parse2object = function(e) {
|
|
156
|
+
return isEmpty(e) ? null : JSON.parse(e);
|
|
157
|
+
}, dataToArray = function(e) {
|
|
158
|
+
return isArray(e) ? e : [ e ];
|
|
159
|
+
};
|
|
221
160
|
|
|
222
161
|
function clone(e) {
|
|
223
|
-
if (null == e || "object" !=
|
|
224
|
-
var t = e,
|
|
225
|
-
n = toString.call(e);
|
|
162
|
+
if (null == e || "object" != (0, _typeof2.default)(e)) return e;
|
|
163
|
+
var t = e, n = toString.call(e);
|
|
226
164
|
if ("[object Array]" === n) {
|
|
227
165
|
t = [];
|
|
228
|
-
for (var r = 0, i = e.length; r < i; r++) t[r] = clone(e[r])
|
|
166
|
+
for (var r = 0, i = e.length; r < i; r++) t[r] = clone(e[r]);
|
|
229
167
|
} else if (TYPED_ARRAY[n]) {
|
|
230
168
|
var o = e.constructor;
|
|
231
|
-
if (e.constructor.from) t = o.from(e);
|
|
232
|
-
else {
|
|
169
|
+
if (e.constructor.from) t = o.from(e); else {
|
|
233
170
|
t = new o(e.length);
|
|
234
|
-
for (var
|
|
171
|
+
for (var u = 0, s = e.length; u < s; u++) t[u] = clone(e[u]);
|
|
235
172
|
}
|
|
236
|
-
} else if (!BUILTIN_OBJECT[n] && !isDom(e))
|
|
237
|
-
|
|
238
|
-
return t
|
|
173
|
+
} else if (!BUILTIN_OBJECT[n] && !isDom(e)) for (var l in t = {}, e) e.hasOwnProperty(l) && (t[l] = clone(e[l]));
|
|
174
|
+
return t;
|
|
239
175
|
}
|
|
240
176
|
|
|
241
177
|
function merge(e, t, n) {
|
|
242
178
|
if (!isObject(t) || !isObject(e)) return n ? clone(t) : e;
|
|
243
|
-
for (var r in t) {
|
|
244
|
-
var i, o;
|
|
245
|
-
|
|
179
|
+
for (var r in t) if (t.hasOwnProperty(r)) {
|
|
180
|
+
var i = e[r], o = t[r];
|
|
181
|
+
!isObject(o) || !isObject(i) || isArray(o) || isArray(i) || isDom(o) || isDom(i) || isBuiltInObject(o) || isBuiltInObject(i) ? !n && r in e || (e[r] = clone(t[r])) : merge(i, o, n);
|
|
246
182
|
}
|
|
247
|
-
return e
|
|
183
|
+
return e;
|
|
248
184
|
}
|
|
249
185
|
|
|
250
186
|
function mergeAll(e, t) {
|
|
251
187
|
for (var n = e[0], r = 1, i = e.length; r < i; r++) n = merge(n, e[r], t);
|
|
252
|
-
return n
|
|
188
|
+
return n;
|
|
253
189
|
}
|
|
190
|
+
|
|
191
|
+
function subObjectEqual(e, t) {
|
|
192
|
+
return !(!isEmpty(e) && !isEmpty(t)) || (e === t || !Object.keys(t).some((function(n) {
|
|
193
|
+
return n in e && t[n] !== e[n];
|
|
194
|
+
})));
|
|
195
|
+
}
|
|
196
|
+
|
|
254
197
|
module.exports = {
|
|
255
198
|
isString: isString,
|
|
256
199
|
isArray: isArray,
|
|
257
200
|
isObject: isObject,
|
|
201
|
+
isOnlyObject: isOnlyObject,
|
|
258
202
|
isBoolean: isBoolean,
|
|
259
203
|
isFunction: isFunction,
|
|
260
204
|
isNumber: isNumber,
|
|
@@ -291,5 +235,6 @@ module.exports = {
|
|
|
291
235
|
dataToArray: dataToArray,
|
|
292
236
|
clone: clone,
|
|
293
237
|
merge: merge,
|
|
294
|
-
mergeAll: mergeAll
|
|
295
|
-
|
|
238
|
+
mergeAll: mergeAll,
|
|
239
|
+
subObjectEqual: subObjectEqual
|
|
240
|
+
};
|
package/lib/xss/htmlEncode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
module.exports = function(e) {
|
|
3
|
-
return null == e || 0 == e.length ? "" : e.replace(/&/g, ">").replace(/</g, "<").replace(/>/, ">").replace(/\s/g, " ").replace(/\'/g, "'").replace(/\"/g, """).replace(/(\r\n|\r|\n)/g, "<br/>")
|
|
4
|
-
};
|
|
4
|
+
return null == e || 0 == e.length ? "" : e.replace(/&/g, ">").replace(/</g, "<").replace(/>/, ">").replace(/\s/g, " ").replace(/\'/g, "'").replace(/\"/g, """).replace(/(\r\n|\r|\n)/g, "<br/>");
|
|
5
|
+
};
|
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var attributes = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
pattern: eventStr,
|
|
31
|
-
flags: [attributes.CASE_INSENSITIVE, attributes.MULTILINE, attributes.DOTALL]
|
|
32
|
-
}), o
|
|
33
|
-
};
|
|
34
|
-
module.exports = function(n) {
|
|
35
|
-
var t = [];
|
|
36
|
-
return getXssPatternList().forEach(function(o) {
|
|
37
|
-
var e = new RegExp(o.pattern, o.flags.join(""));
|
|
38
|
-
t.push(e), n = n.replace(e, "")
|
|
39
|
-
}), n
|
|
4
|
+
CASE_INSENSITIVE: "i",
|
|
5
|
+
MULTILINE: "",
|
|
6
|
+
DOTALL: ""
|
|
7
|
+
}, events = [ "oncontrolselect", "oncopy", "oncut", "ondataavailable", "ondatasetchanged", "ondatasetcomplete", "ondblclick", "ondeactivate", "ondrag", "ondragend", "ondragenter", "ondragleave", "ondragover", "ondragstart", "ondrop", "onerror=", "onerroupdate", "onfilterchange", "onfinish", "onfocus", "onfocusin", "onfocusout", "onhelp", "onkeydown", "onkeypress", "onkeyup", "onlayoutcomplete", "onload", "onlosecapture", "onmousedown", "onmouseenter", "onmouseleave", "onmousemove", "onmousout", "onmouseover", "onmouseup", "onmousewheel", "onmove", "onmoveend", "onmovestart", "onabort", "onactivate", "onafterprint", "onafterupdate", "onbefore", "onbeforeactivate", "onbeforecopy", "onbeforecut", "onbeforedeactivate", "onbeforeeditocus", "onbeforepaste", "onbeforeprint", "onbeforeunload", "onbeforeupdate", "onblur", "onbounce", "oncellchange", "onchange", "onclick", "oncontextmenu", "onpaste", "onpropertychange", "onreadystatechange", "onreset", "onresize", "onresizend", "onresizestart", "onrowenter", "onrowexit", "onrowsdelete", "onrowsinserted", "onscroll", "onselect", "onselectionchange", "onselectstart", "onstart", "onstop", "onsubmit", "onunload" ], eventStr = "<+\\s*\\w*\\s*(oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondblclick|ondeactivate|ondrag|ondragend|ondragenter|ondragleave|ondragover|ondragstart|ondrop|onerror=|onerroupdate|onfilterchange|onfinish|onfocus|onfocusin|onfocusout|onhelp|onkeydown|onkeypress|onkeyup|onlayoutcomplete|onload|onlosecapture|onmousedown|onmouseenter|onmouseleave|onmousemove|onmousout|onmouseover|onmouseup|onmousewheel|onmove|onmoveend|onmovestart|onabort|onactivate|onafterprint|onafterupdate|onbefore|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onblur|onbounce|oncellchange|onchange|onclick|oncontextmenu|onpaste|onpropertychange|onreadystatechange|onreset|onresize|onresizend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onselect|onselectionchange|onselectstart|onstart|onstop|onsubmit|onunload)+\\s*=+", getXssPatternList = function() {
|
|
8
|
+
var o = [];
|
|
9
|
+
return o.push({
|
|
10
|
+
pattern: "<(no)?script[^>]*>.*?</(no)?script>",
|
|
11
|
+
flags: [ attributes.CASE_INSENSITIVE ]
|
|
12
|
+
}), o.push({
|
|
13
|
+
pattern: "eval\\((.*?)\\)",
|
|
14
|
+
flags: [ attributes.CASE_INSENSITIVE, attributes.MULTILINE, attributes.DOTALL ]
|
|
15
|
+
}), o.push({
|
|
16
|
+
pattern: "expression\\((.*?)\\)",
|
|
17
|
+
flags: [ attributes.CASE_INSENSITIVE, attributes.MULTILINE, attributes.DOTALL ]
|
|
18
|
+
}), o.push({
|
|
19
|
+
pattern: "(javascript:|vbscript:|view-source:)*",
|
|
20
|
+
flags: [ attributes.CASE_INSENSITIVE ]
|
|
21
|
+
}), o.push({
|
|
22
|
+
pattern: "<(\"[^\"]*\"|'[^']*'|[^'\">])*>",
|
|
23
|
+
flags: [ attributes.CASE_INSENSITIVE, attributes.MULTILINE, attributes.DOTALL ]
|
|
24
|
+
}), o.push({
|
|
25
|
+
pattern: "(window\\.location|window\\.|\\.location|document\\.cookie|document\\.|alert\\(.*?\\)|window\\.open\\()*",
|
|
26
|
+
flags: [ attributes.CASE_INSENSITIVE, attributes.MULTILINE, attributes.DOTALL ]
|
|
27
|
+
}), o.push({
|
|
28
|
+
pattern: eventStr,
|
|
29
|
+
flags: [ attributes.CASE_INSENSITIVE, attributes.MULTILINE, attributes.DOTALL ]
|
|
30
|
+
}), o;
|
|
40
31
|
};
|
|
32
|
+
|
|
33
|
+
module.exports = function(o) {
|
|
34
|
+
var e = [];
|
|
35
|
+
return getXssPatternList().forEach((function(n) {
|
|
36
|
+
var t = new RegExp(n.pattern, n.flags.join(""));
|
|
37
|
+
e.push(t), o = o.replace(t, "");
|
|
38
|
+
})), o;
|
|
39
|
+
};
|
package/lib/xss/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
var htmlEncode = require("./htmlEncode"), implementEncode = require("./implementEncode");
|
|
4
|
+
|
|
4
5
|
module.exports = {
|
|
5
6
|
htmlEncode: htmlEncode,
|
|
6
7
|
implementEncode: implementEncode
|
|
7
|
-
};
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amos-tool",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.9",
|
|
4
4
|
"description": "amos ui tool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
"testFilter": "mocha tests/tablefilter.test",
|
|
13
13
|
"docs": "node_modules/.bin/jsdoc -c jsdoc-ori.json --readme README.md",
|
|
14
14
|
"build": "ac-build babel-es5",
|
|
15
|
+
"build2": "rollup -c",
|
|
15
16
|
"doc": "ac-doc docall",
|
|
16
|
-
"pub": "npm run build && npm publish"
|
|
17
|
+
"pub": "npm run doc && npm run build && npm publish"
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|
|
@@ -30,16 +31,16 @@
|
|
|
30
31
|
},
|
|
31
32
|
"types": "index.d.ts",
|
|
32
33
|
"homepage": "",
|
|
33
|
-
"dependencies": {
|
|
34
|
+
"dependencies": {
|
|
35
|
+
},
|
|
34
36
|
"devDependencies": {
|
|
35
|
-
"ac-build": "^2.x",
|
|
36
37
|
"assert": "^1.4.1",
|
|
37
38
|
"chai": "~3.4.1",
|
|
38
|
-
"docdash": "
|
|
39
|
-
"
|
|
40
|
-
"jsdoc": "3.5.3",
|
|
39
|
+
"docdash": "1.2.0",
|
|
40
|
+
"jsdoc": "3.6.6",
|
|
41
41
|
"mocha": "^3.4.2",
|
|
42
|
-
"mochawesome": "^2.2.0"
|
|
42
|
+
"mochawesome": "^2.2.0",
|
|
43
|
+
"rollup-toolkit": "^1.x"
|
|
43
44
|
},
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"registry": "https://registry.npmjs.org/"
|