amos-tool 1.4.7 → 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.
Files changed (131) hide show
  1. package/.prettierignore +2 -2
  2. package/.prettierrc +50 -50
  3. package/README.md +667 -667
  4. package/apis/objectPath.md +129 -129
  5. package/index.d.ts +11 -2
  6. package/index.js +3 -3
  7. package/lib/_browser.js +10 -8
  8. package/lib/_clone.js +68 -57
  9. package/lib/_cookie.js +50 -47
  10. package/lib/_deepCopy.js +14 -19
  11. package/lib/_deepEqual.js +7 -8
  12. package/lib/_fastDeepEqual.js +26 -34
  13. package/lib/_flashSupport.js +13 -10
  14. package/lib/_forOwn.js +8 -7
  15. package/lib/_funcThrottle.js +16 -15
  16. package/lib/_isnode.js +2 -1
  17. package/lib/_list.js +74 -79
  18. package/lib/_object.assign.js +19 -19
  19. package/lib/_object.entries.js +8 -7
  20. package/lib/_object.values.js +8 -7
  21. package/lib/_omit.js +12 -11
  22. package/lib/_parseJson.js +7 -6
  23. package/lib/_pick.js +8 -7
  24. package/lib/_queue.js +24 -21
  25. package/lib/_shallowCopy.js +24 -23
  26. package/lib/_stringify.js +13 -10
  27. package/lib/_supportWs.js +5 -5
  28. package/lib/_trim.js +5 -4
  29. package/lib/_typeOfList.js +22 -21
  30. package/lib/_uuids.js +30 -35
  31. package/lib/amostool.js +4 -66
  32. package/lib/array2tree.js +9 -9
  33. package/lib/arrayFilter.js +18 -19
  34. package/lib/arrayUtils.js +10 -8
  35. package/lib/browser/Cookie.js +35 -36
  36. package/lib/browser/indexDB.js +72 -71
  37. package/lib/browserSupport.js +76 -71
  38. package/lib/completeUnit.js +7 -4
  39. package/lib/consts.js +2 -1
  40. package/lib/dom/canvas2img.js +61 -72
  41. package/lib/dom/canvasTools.js +11 -16
  42. package/lib/dom/downloadFile.js +17 -12
  43. package/lib/dom/eventHelper.js +8 -6
  44. package/lib/dom/fileBlob.js +14 -14
  45. package/lib/dom/fileSaveAs.js +54 -61
  46. package/lib/dom/getFontSize.js +7 -10
  47. package/lib/dom/minfyImg.js +27 -24
  48. package/lib/encrypt/_base64.js +32 -25
  49. package/lib/encrypt/_md5.js +68 -31
  50. package/lib/encrypt/des.js +430 -366
  51. package/lib/extra/_common.js +120 -161
  52. package/lib/extra/filterNull.js +5 -4
  53. package/lib/extra/find.js +10 -11
  54. package/lib/extra/index.js +4 -3
  55. package/lib/extra/memo.js +18 -0
  56. package/lib/extra/pathToTree.js +49 -36
  57. package/lib/extra/pwdStrength.js +4 -2
  58. package/lib/extra/sortBy.js +28 -30
  59. package/lib/flat.js +9 -13
  60. package/lib/locationParams.js +93 -95
  61. package/lib/log.js +20 -26
  62. package/lib/math/_keyColor.js +3 -1
  63. package/lib/math/addition.js +9 -7
  64. package/lib/math/amountCase.js +8 -12
  65. package/lib/math/coinFormat.js +6 -4
  66. package/lib/math/colorUtil.js +91 -94
  67. package/lib/math/dateTime.js +79 -97
  68. package/lib/math/operations.js +33 -37
  69. package/lib/math/pwdStrength.js +4 -2
  70. package/lib/math/randomColor.js +17 -5
  71. package/lib/math/subtraction.js +10 -9
  72. package/lib/merged.js +9 -9
  73. package/lib/objectPath.js +81 -82
  74. package/lib/parseText.js +8 -7
  75. package/lib/png/Identicon.js +32 -28
  76. package/lib/png/pnglib.js +59 -34
  77. package/lib/png/randomPic.js +8 -14
  78. package/lib/positionFactory.js +28 -28
  79. package/lib/pwdPolicy.js +27 -31
  80. package/lib/qs/_assign.js +7 -5
  81. package/lib/qs/_merge.js +20 -23
  82. package/lib/qs/_tools.js +3 -2
  83. package/lib/qs/formats.js +6 -5
  84. package/lib/qs/index.js +4 -4
  85. package/lib/qs/parse.js +56 -51
  86. package/lib/qs/stringify.js +54 -69
  87. package/lib/qs/utils.js +70 -83
  88. package/lib/random.js +5 -4
  89. package/lib/shallowEqual.js +25 -29
  90. package/lib/store.js +93 -95
  91. package/lib/strUtils.js +52 -43
  92. package/lib/tableFilter.js +178 -169
  93. package/lib/throttleDebounce.js +18 -22
  94. package/lib/url/encodeUrl.js +5 -4
  95. package/lib/url/restfulUrl.js +8 -7
  96. package/lib/utils.js +171 -222
  97. package/lib/xss/htmlEncode.js +3 -2
  98. package/lib/xss/implementEncode.js +36 -37
  99. package/lib/xss/index.js +4 -3
  100. package/package.json +4 -4
  101. package/docs/Logger.html +0 -189
  102. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  103. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  104. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  105. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  106. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  107. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  108. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  109. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  110. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  111. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
  112. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  113. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  114. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  115. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  116. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
  117. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  118. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  119. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  120. package/docs/global.html +0 -14535
  121. package/docs/index.html +0 -791
  122. package/docs/scripts/collapse.js +0 -20
  123. package/docs/scripts/linenumber.js +0 -25
  124. package/docs/scripts/nav.js +0 -12
  125. package/docs/scripts/polyfill.js +0 -4
  126. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  127. package/docs/scripts/prettify/lang-css.js +0 -2
  128. package/docs/scripts/prettify/prettify.js +0 -28
  129. package/docs/scripts/search.js +0 -83
  130. package/docs/styles/jsdoc.css +0 -765
  131. package/docs/styles/prettify.css +0 -79
@@ -1,129 +1,129 @@
1
- # objectPath
2
-
3
- ## Usage
4
-
5
- ```js
6
- var {objectPath} from 'amos-tool';
7
-
8
- var obj = {
9
- a: {
10
- b: "d",
11
- c: ["e", "f"],
12
- '\u1200': 'unicode key',
13
- 'dot.dot': 'key'
14
- }
15
- };
16
-
17
- var objectPath = require("object-path");
18
-
19
- //get deep property
20
- objectPath.get(obj, "a.b"); //returns "d"
21
- objectPath.get(obj, ["a", "dot.dot"]); //returns "key"
22
- objectPath.get(obj, 'a.\u1200'); //returns "unicode key"
23
-
24
- //get the first non-undefined value
25
- objectPath.coalesce(obj, ['a.z', 'a.d', ['a','b']], 'default');
26
-
27
- //empty a given path (but do not delete it) depending on their type,so it retains reference to objects and arrays.
28
- //functions that are not inherited from prototype are set to null.
29
- //object instances are considered objects and just own property names are deleted
30
- objectPath.empty(obj, 'a.b'); // obj.a.b is now ''
31
- objectPath.empty(obj, 'a.c'); // obj.a.c is now []
32
- objectPath.empty(obj, 'a'); // obj.a is now {}
33
-
34
- //works also with arrays
35
- objectPath.get(obj, "a.c.1"); //returns "f"
36
- objectPath.get(obj, ["a","c","1"]); //returns "f"
37
-
38
- //can return a default value with get
39
- objectPath.get(obj, ["a.c.b"], "DEFAULT"); //returns "DEFAULT", since a.c.b path doesn't exists, if omitted, returns undefined
40
-
41
- //set
42
- objectPath.set(obj, "a.h", "m"); // or objectPath.set(obj, ["a","h"], "m");
43
- objectPath.get(obj, "a.h"); //returns "m"
44
-
45
- //set will create intermediate object/arrays
46
- objectPath.set(obj, "a.j.0.f", "m");
47
-
48
- //will insert values in array
49
- objectPath.insert(obj, "a.c", "m", 1); // obj.a.c = ["e", "m", "f"]
50
-
51
- //push into arrays (and create intermediate objects/arrays)
52
- objectPath.push(obj, "a.k", "o");
53
-
54
- //ensure a path exists (if it doesn't, set the default value you provide)
55
- objectPath.ensureExists(obj, "a.k.1", "DEFAULT");
56
- var oldVal = objectPath.ensureExists(obj, "a.b", "DEFAULT"); // oldval === "d"
57
-
58
- //deletes a path
59
- objectPath.del(obj, "a.b"); // obj.a.b is now undefined
60
- objectPath.del(obj, ["a","c",0]); // obj.a.c is now ['f']
61
-
62
- //tests path existence
63
- objectPath.has(obj, "a.b"); // true
64
- objectPath.has(obj, ["a","d"]); // false
65
-
66
- //bind object
67
- var model = objectPath({
68
- a: {
69
- b: "d",
70
- c: ["e", "f"]
71
- }
72
- });
73
-
74
- //now any method from above is supported directly w/o passing an object
75
- model.get("a.b"); //returns "d"
76
- model.get(["a.c.b"], "DEFAULT"); //returns "DEFAULT"
77
- model.del("a.b"); // obj.a.b is now undefined
78
- model.has("a.b"); // false
79
-
80
- ```
81
-
82
- ### How `object-path` deals with inherited properties
83
-
84
- By default `object-path` will only access an object's own properties. Look at the following example:
85
-
86
- ```js
87
- var proto = {
88
- notOwn: {prop: 'a'}
89
- }
90
- var obj = Object.create(proto);
91
-
92
- //This will return undefined (or the default value you specified), because notOwn is
93
- //an inherited property
94
- objectPath.get(obj, 'notOwn.prop');
95
-
96
- //This will set the property on the obj instance and not the prototype.
97
- //In other words proto.notOwn.prop === 'a' and obj.notOwn.prop === 'b'
98
- objectPath.set(obj, 'notOwn.prop', 'b');
99
- ```
100
-
101
- To configure `object-path` to also deal with inherited properties, you need to create a new instance and specify
102
- the `includeInheritedProps = true` in the options object:
103
-
104
- ```js
105
- var objectPath = require("object-path");
106
- var objectPathWithInheritedProps = objectPath.create({includeInheritedProps: true})
107
- ```
108
-
109
- Alternatively, `object-path` exposes an instance already configured to handle inherited properties (`objectPath.withInheritedProps`):
110
-
111
- ```js
112
- var objectPath = require("object-path");
113
- var objectPathWithInheritedProps = objectPath.withInheritedProps
114
- ```
115
-
116
- Once you have the new instance, you can access inherited properties as you access other properties:
117
-
118
- ```js
119
- var proto = {
120
- notOwn: {prop: 'a'}
121
- }
122
- var obj = Object.create(proto);
123
-
124
- //This will return 'a'
125
- objectPath.withInheritedProps.get(obj, 'notOwn.prop');
126
-
127
- //This will set proto.notOwn.prop to 'b'
128
- objectPath.set(obj, 'notOwn.prop', 'b');
129
- ```
1
+ # objectPath
2
+
3
+ ## Usage
4
+
5
+ ```js
6
+ var {objectPath} from 'amos-tool';
7
+
8
+ var obj = {
9
+ a: {
10
+ b: "d",
11
+ c: ["e", "f"],
12
+ '\u1200': 'unicode key',
13
+ 'dot.dot': 'key'
14
+ }
15
+ };
16
+
17
+ var objectPath = require("object-path");
18
+
19
+ //get deep property
20
+ objectPath.get(obj, "a.b"); //returns "d"
21
+ objectPath.get(obj, ["a", "dot.dot"]); //returns "key"
22
+ objectPath.get(obj, 'a.\u1200'); //returns "unicode key"
23
+
24
+ //get the first non-undefined value
25
+ objectPath.coalesce(obj, ['a.z', 'a.d', ['a','b']], 'default');
26
+
27
+ //empty a given path (but do not delete it) depending on their type,so it retains reference to objects and arrays.
28
+ //functions that are not inherited from prototype are set to null.
29
+ //object instances are considered objects and just own property names are deleted
30
+ objectPath.empty(obj, 'a.b'); // obj.a.b is now ''
31
+ objectPath.empty(obj, 'a.c'); // obj.a.c is now []
32
+ objectPath.empty(obj, 'a'); // obj.a is now {}
33
+
34
+ //works also with arrays
35
+ objectPath.get(obj, "a.c.1"); //returns "f"
36
+ objectPath.get(obj, ["a","c","1"]); //returns "f"
37
+
38
+ //can return a default value with get
39
+ objectPath.get(obj, ["a.c.b"], "DEFAULT"); //returns "DEFAULT", since a.c.b path doesn't exists, if omitted, returns undefined
40
+
41
+ //set
42
+ objectPath.set(obj, "a.h", "m"); // or objectPath.set(obj, ["a","h"], "m");
43
+ objectPath.get(obj, "a.h"); //returns "m"
44
+
45
+ //set will create intermediate object/arrays
46
+ objectPath.set(obj, "a.j.0.f", "m");
47
+
48
+ //will insert values in array
49
+ objectPath.insert(obj, "a.c", "m", 1); // obj.a.c = ["e", "m", "f"]
50
+
51
+ //push into arrays (and create intermediate objects/arrays)
52
+ objectPath.push(obj, "a.k", "o");
53
+
54
+ //ensure a path exists (if it doesn't, set the default value you provide)
55
+ objectPath.ensureExists(obj, "a.k.1", "DEFAULT");
56
+ var oldVal = objectPath.ensureExists(obj, "a.b", "DEFAULT"); // oldval === "d"
57
+
58
+ //deletes a path
59
+ objectPath.del(obj, "a.b"); // obj.a.b is now undefined
60
+ objectPath.del(obj, ["a","c",0]); // obj.a.c is now ['f']
61
+
62
+ //tests path existence
63
+ objectPath.has(obj, "a.b"); // true
64
+ objectPath.has(obj, ["a","d"]); // false
65
+
66
+ //bind object
67
+ var model = objectPath({
68
+ a: {
69
+ b: "d",
70
+ c: ["e", "f"]
71
+ }
72
+ });
73
+
74
+ //now any method from above is supported directly w/o passing an object
75
+ model.get("a.b"); //returns "d"
76
+ model.get(["a.c.b"], "DEFAULT"); //returns "DEFAULT"
77
+ model.del("a.b"); // obj.a.b is now undefined
78
+ model.has("a.b"); // false
79
+
80
+ ```
81
+
82
+ ### How `object-path` deals with inherited properties
83
+
84
+ By default `object-path` will only access an object's own properties. Look at the following example:
85
+
86
+ ```js
87
+ var proto = {
88
+ notOwn: {prop: 'a'}
89
+ }
90
+ var obj = Object.create(proto);
91
+
92
+ //This will return undefined (or the default value you specified), because notOwn is
93
+ //an inherited property
94
+ objectPath.get(obj, 'notOwn.prop');
95
+
96
+ //This will set the property on the obj instance and not the prototype.
97
+ //In other words proto.notOwn.prop === 'a' and obj.notOwn.prop === 'b'
98
+ objectPath.set(obj, 'notOwn.prop', 'b');
99
+ ```
100
+
101
+ To configure `object-path` to also deal with inherited properties, you need to create a new instance and specify
102
+ the `includeInheritedProps = true` in the options object:
103
+
104
+ ```js
105
+ var objectPath = require("object-path");
106
+ var objectPathWithInheritedProps = objectPath.create({includeInheritedProps: true})
107
+ ```
108
+
109
+ Alternatively, `object-path` exposes an instance already configured to handle inherited properties (`objectPath.withInheritedProps`):
110
+
111
+ ```js
112
+ var objectPath = require("object-path");
113
+ var objectPathWithInheritedProps = objectPath.withInheritedProps
114
+ ```
115
+
116
+ Once you have the new instance, you can access inherited properties as you access other properties:
117
+
118
+ ```js
119
+ var proto = {
120
+ notOwn: {prop: 'a'}
121
+ }
122
+ var obj = Object.create(proto);
123
+
124
+ //This will return 'a'
125
+ objectPath.withInheritedProps.get(obj, 'notOwn.prop');
126
+
127
+ //This will set proto.notOwn.prop to 'b'
128
+ objectPath.set(obj, 'notOwn.prop', 'b');
129
+ ```
package/index.d.ts CHANGED
@@ -169,11 +169,14 @@ declare namespace LocationParam {
169
169
  export function parse(paramString: string): object;
170
170
  export function paramSearch(_name: string, target: string): void;
171
171
  /**
172
- * 获取 location 中的所有参数
172
+ * - 获取 location 中的所有参数
173
+ * - 对 location.href 进行查找,支持 hash 方式的路由
173
174
  */
174
175
  export function getLocationParams(): object;
175
176
  /**
176
- * 获取 location 中的参数
177
+ * - 获取 location 中的参数。
178
+ * - 采用 location.search 进行查找,因此,如果采用 react-router hash 方式,将无法获取到参数
179
+ * - why not support hash router? because in hash router location.search=''
177
180
  * @param name
178
181
  */
179
182
  export function getLocationParamByName(name: string): string | null;
@@ -986,6 +989,12 @@ declare namespace utils {
986
989
  * @return target
987
990
  */
988
991
  export function mergeAll(targetAndSources: Array<any>, overwrite?: boolean): object | Array<any>;
992
+ /**
993
+ * 比较 objTarget 中的所有属性值,是否在 objSource 中相等
994
+ * @param objSource
995
+ * @param objTarget
996
+ */
997
+ export function subObjectEqual(objSource: {}, objTarget: {}): Boolean;
989
998
  }
990
999
 
991
1000
  declare namespace throttleDebounce {
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var amostool = require('./lib/amostool');
2
-
3
- module.exports = amostool;
1
+ var amostool = require('./lib/amostool');
2
+
3
+ module.exports = amostool;
package/lib/_browser.js CHANGED
@@ -1,25 +1,27 @@
1
1
  "use strict";
2
+
2
3
  var Browser = {
3
4
  isFirefox: function() {
4
- return "undefined" != typeof InstallTrigger
5
+ return "undefined" != typeof InstallTrigger;
5
6
  },
6
7
  isIE: function() {
7
- return !!document.documentMode
8
+ return !!document.documentMode;
8
9
  },
9
10
  isEdge: function() {
10
- return !Browser.isIE() && !!window.StyleMedia
11
+ return !Browser.isIE() && !!window.StyleMedia;
11
12
  },
12
13
  isChrome: function() {
13
- return !!window.chrome && !!window.chrome.webstore
14
+ return !!window.chrome && !!window.chrome.webstore;
14
15
  },
15
16
  isSafari: function() {
16
- return 0 < Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") || -1 !== navigator.userAgent.toLowerCase().indexOf("safari")
17
+ return Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") > 0 || -1 !== navigator.userAgent.toLowerCase().indexOf("safari");
17
18
  },
18
19
  wp: function() {
19
- navigator.userAgent.match(/Windows Phone ([\d.]+)/)
20
+ navigator.userAgent.match(/Windows Phone ([\d.]+)/);
20
21
  },
21
22
  android: function() {
22
- navigator.userAgent.match(/(Android);?[\s\/]+([\d.]+)?/)
23
+ navigator.userAgent.match(/(Android);?[\s\/]+([\d.]+)?/);
23
24
  }
24
25
  };
25
- module.exports = Browser;
26
+
27
+ module.exports = Browser;
package/lib/_clone.js CHANGED
@@ -1,68 +1,79 @@
1
1
  "use strict";
2
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"),
3
- _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")),
4
- findType = function(e) {
5
- return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]
6
- };
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), findType = function(e) {
4
+ return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1];
5
+ };
7
6
 
8
7
  function findAllType(e) {
9
8
  switch (Object.prototype.toString.call(e)) {
10
- case "[object Date]":
11
- return "date";
12
- case "[object RegExp]":
13
- return "regexp";
14
- case "[object Arguments]":
15
- return "arguments";
16
- case "[object Array]":
17
- return "array";
18
- case "[object Error]":
19
- return "error"
9
+ case "[object Date]":
10
+ return "date";
11
+
12
+ case "[object RegExp]":
13
+ return "regexp";
14
+
15
+ case "[object Arguments]":
16
+ return "arguments";
17
+
18
+ case "[object Array]":
19
+ return "array";
20
+
21
+ case "[object Error]":
22
+ return "error";
20
23
  }
21
- return null === e ? "null" : void 0 === e ? "undefined" : e && 1 === e.nodeType ? "element" : (e = e.valueOf ? e.valueOf() : Object.prototype.valueOf.apply(e), (0, _typeof2.default)(e))
24
+ return null === e ? "null" : void 0 === e ? "undefined" : e && 1 === e.nodeType ? "element" : (e = e.valueOf ? e.valueOf() : Object.prototype.valueOf.apply(e),
25
+ (0, _typeof2.default)(e));
22
26
  }
27
+
23
28
  var simpleClone = function e(r) {
24
- switch (findType(r)) {
25
- case "Object":
26
- var t, n = {};
27
- for (t in r) r.hasOwnProperty(t) && (n[t] = e(r[t]));
28
- return n;
29
- case "Array":
30
- return r.slice()
31
- }
32
- return r
33
- },
34
- clone = function(r) {
35
- try {
36
- return JSON.parse(JSON.stringify(r, function(e, r) {
37
- return "function" == typeof r ? r.toString() : r
38
- }))
39
- } catch (e) {
40
- return r
41
- }
42
- },
43
- cloneAll = function r(t) {
44
- switch (findAllType(t)) {
45
- case "object":
46
- var n = {};
47
- return Object.keys(t).forEach(function(e) {
48
- "$" !== e.charAt(0) && (n[e] = r(t[e]))
49
- }), n;
50
- case "element":
51
- return t.cloneNode(!0);
52
- case "array":
53
- for (var e = new Array(t.length), o = 0, l = t.length; o < l; o++) e[o] = r(t[o]);
54
- return e;
55
- case "regexp":
56
- var c = "";
57
- return c += t.multiline ? "m" : "", c += t.global ? "g" : "", c += t.ignoreCase ? "i" : "", new RegExp(t.source, c);
58
- case "date":
59
- return new Date(t.getTime());
60
- default:
61
- return t
62
- }
63
- };
29
+ switch (findType(r)) {
30
+ case "Object":
31
+ var t = {};
32
+ for (var n in r) r.hasOwnProperty(n) && (t[n] = e(r[n]));
33
+ return t;
34
+
35
+ case "Array":
36
+ return r.slice();
37
+ }
38
+ return r;
39
+ }, clone = function(e) {
40
+ try {
41
+ return JSON.parse(JSON.stringify(e, (function(e, r) {
42
+ return "function" == typeof r ? r.toString() : r;
43
+ })));
44
+ } catch (r) {
45
+ return e;
46
+ }
47
+ }, cloneAll = function e(r) {
48
+ switch (findAllType(r)) {
49
+ case "object":
50
+ var t = {};
51
+ return Object.keys(r).forEach((function(n) {
52
+ "$" !== n.charAt(0) && (t[n] = e(r[n]));
53
+ })), t;
54
+
55
+ case "element":
56
+ return r.cloneNode(!0);
57
+
58
+ case "array":
59
+ for (var n = new Array(r.length), o = 0, l = r.length; o < l; o++) n[o] = e(r[o]);
60
+ return n;
61
+
62
+ case "regexp":
63
+ var a = "";
64
+ return a += r.multiline ? "m" : "", a += r.global ? "g" : "", a += r.ignoreCase ? "i" : "",
65
+ new RegExp(r.source, a);
66
+
67
+ case "date":
68
+ return new Date(r.getTime());
69
+
70
+ default:
71
+ return r;
72
+ }
73
+ };
74
+
64
75
  module.exports = {
65
76
  simpleClone: simpleClone,
66
77
  clone: clone,
67
78
  cloneAll: cloneAll
68
- };
79
+ };
package/lib/_cookie.js CHANGED
@@ -1,68 +1,71 @@
1
1
  "use strict";
2
- var decode = decodeURIComponent,
3
- encode = encodeURIComponent,
4
- pairSplitRegExp = /; */,
5
- fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
2
+
3
+ var decode = decodeURIComponent, encode = encodeURIComponent, pairSplitRegExp = /; */, fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
6
4
 
7
5
  function parse(e, t) {
8
6
  if ("string" != typeof e) throw new TypeError("argument str must be a string");
9
- for (var i = {}, t = t || {}, r = e.split(pairSplitRegExp), n = t.decode || decode, o = 0; o < r.length; o++) {
10
- var a, s = r[o],
11
- p = s.indexOf("=");
12
- p < 0 || (a = s.substr(0, p).trim(), '"' == (s = s.substr(++p, s.length).trim())[0] && (s = s.slice(1, -1)), null == i[a] && (i[a] = tryDecode(s, n)))
7
+ for (var r = {}, i = t || {}, n = e.split(pairSplitRegExp), o = i.decode || decode, a = 0; a < n.length; a++) {
8
+ var s = n[a], p = s.indexOf("=");
9
+ if (!(p < 0)) {
10
+ var d = s.substr(0, p).trim(), f = s.substr(++p, s.length).trim();
11
+ '"' == f[0] && (f = f.slice(1, -1)), null == r[d] && (r[d] = tryDecode(f, o));
12
+ }
13
13
  }
14
- return i
14
+ return r;
15
15
  }
16
16
 
17
- function serialize(e, t, i) {
18
- var r = i || {},
19
- i = r.encode || encode;
20
- if ("function" != typeof i) throw new TypeError("option encode is invalid");
17
+ function serialize(e, t, r) {
18
+ var i = r || {}, n = i.encode || encode;
19
+ if ("function" != typeof n) throw new TypeError("option encode is invalid");
21
20
  if (!fieldContentRegExp.test(e)) throw new TypeError("argument name is invalid");
22
- t = i(t);
23
- if (t && !fieldContentRegExp.test(t)) throw new TypeError("argument val is invalid");
24
- var n = e + "=" + t;
25
- if (null != r.maxAge) {
26
- t = +r.maxAge;
27
- if (isNaN(t)) throw new Error("maxAge should be a Number");
28
- n += "; Max-Age=" + Math.floor(t)
21
+ var o = n(t);
22
+ if (o && !fieldContentRegExp.test(o)) throw new TypeError("argument val is invalid");
23
+ var a = e + "=" + o;
24
+ if (null != i.maxAge) {
25
+ var s = i.maxAge - 0;
26
+ if (isNaN(s)) throw new Error("maxAge should be a Number");
27
+ a += "; Max-Age=" + Math.floor(s);
29
28
  }
30
- if (r.domain) {
31
- if (!fieldContentRegExp.test(r.domain)) throw new TypeError("option domain is invalid");
32
- n += "; Domain=" + r.domain
29
+ if (i.domain) {
30
+ if (!fieldContentRegExp.test(i.domain)) throw new TypeError("option domain is invalid");
31
+ a += "; Domain=" + i.domain;
33
32
  }
34
- if (r.path) {
35
- if (!fieldContentRegExp.test(r.path)) throw new TypeError("option path is invalid");
36
- n += "; Path=" + r.path
33
+ if (i.path) {
34
+ if (!fieldContentRegExp.test(i.path)) throw new TypeError("option path is invalid");
35
+ a += "; Path=" + i.path;
37
36
  }
38
- if (r.expires) {
39
- if ("function" != typeof r.expires.toUTCString) throw new TypeError("option expires is invalid");
40
- n += "; Expires=" + r.expires.toUTCString()
37
+ if (i.expires) {
38
+ if ("function" != typeof i.expires.toUTCString) throw new TypeError("option expires is invalid");
39
+ a += "; Expires=" + i.expires.toUTCString();
41
40
  }
42
- if (r.httpOnly && (n += "; HttpOnly"), r.secure && (n += "; Secure"), r.sameSite) switch ("string" == typeof r.sameSite ? r.sameSite.toLowerCase() : r.sameSite) {
43
- case !0:
44
- n += "; SameSite=Strict";
45
- break;
46
- case "lax":
47
- n += "; SameSite=Lax";
48
- break;
49
- case "strict":
50
- n += "; SameSite=Strict";
51
- break;
52
- default:
53
- throw new TypeError("option sameSite is invalid")
41
+ if (i.httpOnly && (a += "; HttpOnly"), i.secure && (a += "; Secure"), i.sameSite) switch ("string" == typeof i.sameSite ? i.sameSite.toLowerCase() : i.sameSite) {
42
+ case !0:
43
+ a += "; SameSite=Strict";
44
+ break;
45
+
46
+ case "lax":
47
+ a += "; SameSite=Lax";
48
+ break;
49
+
50
+ case "strict":
51
+ a += "; SameSite=Strict";
52
+ break;
53
+
54
+ default:
55
+ throw new TypeError("option sameSite is invalid");
54
56
  }
55
- return n
57
+ return a;
56
58
  }
57
59
 
58
- function tryDecode(t, e) {
60
+ function tryDecode(e, t) {
59
61
  try {
60
- return e(t)
61
- } catch (e) {
62
- return t
62
+ return t(e);
63
+ } catch (t) {
64
+ return e;
63
65
  }
64
66
  }
67
+
65
68
  module.exports = {
66
69
  parse: parse,
67
70
  serialize: serialize
68
- };
71
+ };
package/lib/_deepCopy.js CHANGED
@@ -1,30 +1,25 @@
1
1
  "use strict";
2
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"),
3
- _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")),
4
- _typeOfList = require("./_typeOfList"),
5
- utils = require("./utils"),
6
- BUILTIN_OBJECT = _typeOfList.BUILTIN_OBJECT,
7
- TYPED_ARRAY = _typeOfList.TYPED_ARRAY;
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), _typeOfList = require("./_typeOfList"), utils = require("./utils"), BUILTIN_OBJECT = _typeOfList.BUILTIN_OBJECT, TYPED_ARRAY = _typeOfList.TYPED_ARRAY;
8
4
 
9
5
  function eq(e, r) {
10
- return e === r || e != e && r != r
6
+ return e === r || e != e && r != r;
11
7
  }
12
8
 
13
9
  function deepCopy(e) {
14
10
  if (null == e || "object" != (0, _typeof2.default)(e)) return e;
15
- var r = e,
16
- t = Object.prototype.toString.call(e);
17
- if ("[object Array]" === t)
18
- for (var r = [], o = 0, i = e.length; o < i; o++) r[o] = deepCopy(e[o]);
19
- else if (TYPED_ARRAY[t]) {
11
+ var r = e, t = Object.prototype.toString.call(e);
12
+ if ("[object Array]" === t) {
13
+ r = [];
14
+ for (var o = 0, i = e.length; o < i; o++) r[o] = deepCopy(e[o]);
15
+ } else if (TYPED_ARRAY[t]) {
20
16
  var p = e.constructor;
21
- if (e.constructor.from) r = p.from(e);
22
- else {
17
+ if (e.constructor.from) r = p.from(e); else {
23
18
  r = new p(e.length);
24
- for (var u = 0, f = e.length; u < f; u++) r[u] = deepCopy(e[u])
19
+ for (var u = 0, f = e.length; u < f; u++) r[u] = deepCopy(e[u]);
25
20
  }
26
- } else if (!BUILTIN_OBJECT[t] && !utils.isDom(e))
27
- for (var l in r = {}, e) e.hasOwnProperty(l) && (r[l] = deepCopy(e[l]));
28
- return r
21
+ } else if (!BUILTIN_OBJECT[t] && !utils.isDom(e)) for (var l in r = {}, e) e.hasOwnProperty(l) && (r[l] = deepCopy(e[l]));
22
+ return r;
29
23
  }
30
- module.exports = deepCopy, module.exports.eq = eq;
24
+
25
+ module.exports = deepCopy, module.exports.eq = eq;
package/lib/_deepEqual.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"),
3
- _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")),
4
- stringify = require("./_stringify"),
5
- utils = require("./utils"),
6
- deepEqual = function(e, i) {
7
- return !(utils.isEmpty(e) && !utils.isEmpty(i) || !utils.isEmpty(e) && utils.isEmpty(i)) && ((0, _typeof2.default)(e) === (0, _typeof2.default)(i) && (utils.isString(e) && utils.isString(i) || utils.isNumber(e) && utils.isNumber(i) ? e === i : stringify(e) === stringify(i)))
8
- };
9
- module.exports = deepEqual;
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), stringify = require("./_stringify"), utils = require("./utils"), deepEqual = function(e, i) {
4
+ return !(utils.isEmpty(e) && !utils.isEmpty(i) || !utils.isEmpty(e) && utils.isEmpty(i)) && ((0,
5
+ _typeof2.default)(e) === (0, _typeof2.default)(i) && (utils.isString(e) && utils.isString(i) || utils.isNumber(e) && utils.isNumber(i) ? e === i : stringify(e) === stringify(i)));
6
+ };
7
+
8
+ module.exports = deepEqual;