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.
Files changed (100) hide show
  1. package/.prettierignore +2 -2
  2. package/.prettierrc +50 -50
  3. package/README.md +667 -653
  4. package/apis/objectPath.md +129 -129
  5. package/index.d.ts +50 -5
  6. package/index.js +3 -3
  7. package/lib/_browser.js +10 -8
  8. package/lib/_clone.js +67 -62
  9. package/lib/_cookie.js +35 -32
  10. package/lib/_deepCopy.js +17 -29
  11. package/lib/_deepEqual.js +6 -13
  12. package/lib/_fastDeepEqual.js +28 -44
  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 +55 -67
  18. package/lib/_object.assign.js +14 -24
  19. package/lib/_object.entries.js +6 -5
  20. package/lib/_object.values.js +5 -4
  21. package/lib/_omit.js +12 -12
  22. package/lib/_parseJson.js +7 -6
  23. package/lib/_pick.js +14 -0
  24. package/lib/_queue.js +24 -21
  25. package/lib/_shallowCopy.js +24 -23
  26. package/lib/_stringify.js +14 -17
  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 +15 -63
  32. package/lib/array2tree.js +9 -10
  33. package/lib/arrayFilter.js +17 -20
  34. package/lib/arrayUtils.js +13 -11
  35. package/lib/browser/Cookie.js +34 -35
  36. package/lib/browser/indexDB.js +71 -82
  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 -73
  41. package/lib/dom/canvasTools.js +9 -14
  42. package/lib/dom/downloadFile.js +15 -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 +30 -25
  48. package/lib/encrypt/_base64.js +32 -25
  49. package/lib/encrypt/_md5.js +68 -31
  50. package/lib/encrypt/des.js +426 -363
  51. package/lib/extra/_common.js +119 -166
  52. package/lib/extra/filterNull.js +3 -2
  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 +48 -42
  57. package/lib/extra/pwdStrength.js +4 -2
  58. package/lib/extra/sortBy.js +28 -30
  59. package/lib/flat.js +15 -0
  60. package/lib/locationParams.js +94 -99
  61. package/lib/log.js +20 -26
  62. package/lib/math/_keyColor.js +154 -0
  63. package/lib/math/addition.js +9 -7
  64. package/lib/math/amountCase.js +8 -12
  65. package/lib/math/coinFormat.js +7 -5
  66. package/lib/math/colorUtil.js +96 -92
  67. package/lib/math/dateTime.js +76 -94
  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 +88 -95
  74. package/lib/parseText.js +8 -7
  75. package/lib/png/Identicon.js +36 -38
  76. package/lib/png/pnglib.js +58 -32
  77. package/lib/png/randomPic.js +9 -12
  78. package/lib/positionFactory.js +25 -80
  79. package/lib/pwdPolicy.js +27 -31
  80. package/lib/qs/_assign.js +7 -5
  81. package/lib/qs/_merge.js +19 -28
  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 +55 -50
  86. package/lib/qs/stringify.js +55 -77
  87. package/lib/qs/utils.js +69 -88
  88. package/lib/random.js +5 -4
  89. package/lib/shallowEqual.js +24 -34
  90. package/lib/store.js +93 -98
  91. package/lib/strUtils.js +51 -42
  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 +169 -223
  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 +9 -8
@@ -1,108 +1,103 @@
1
1
  "use strict";
2
- var utils = require("./utils"),
3
- _LSFN = function() {
4
- var i = [];
5
- return function() {
6
- var t = window.location.search;
7
- if (utils.isEmpty(t)) throw new Error("the [window.location.search] not empty!");
8
- var n = 1 < t.length ? t.substring(1) : null;
9
- utils.isNull(n) || (i = [].slice.call(n.split("&")))
10
- }(), {
11
- getValue: function(e) {
12
- i.forEach(function(t) {
13
- var n = t.split("=");
14
- if (n[0] === e) return n[1]
15
- })
16
- },
17
- getParameters: function() {
18
- var n = [];
19
- return i.forEach(function(t) {
20
- n.push(t.split("=")[0])
21
- }), n
22
- }
23
- }
24
- },
25
- _LocationSearch = {
26
- _keyValuePairs: [],
27
- init: function() {
28
- var t = window.location.search;
29
- if (utils.isEmpty(t)) throw new Error("the [window.location.search] not empty!");
30
- var n = 1 < t.length ? t.substring(1) : null;
31
- return utils.isNull(n) || (_LocationSearch._keyValuePairs = [].slice.call(n.split("&"))), this
32
- },
33
- getValue: function(e) {
34
- _LocationSearch._keyValuePairs.forEach(function(t) {
35
- var n = t.split("=");
36
- if (n[0] === e) return n[1]
37
- })
2
+
3
+ var utils = require("./utils"), _LSFN = function() {
4
+ var t = [];
5
+ return function() {
6
+ var n = window.location.search;
7
+ if (utils.isEmpty(n)) throw new Error("the [window.location.search] not empty!");
8
+ var e = n.length > 1 ? n.substring(1) : null;
9
+ utils.isNull(e) || (t = [].slice.call(e.split("&")));
10
+ }(), {
11
+ getValue: function(n) {
12
+ t.forEach((function(t) {
13
+ var e = t.split("=");
14
+ if (e[0] === n) return e[1];
15
+ }));
38
16
  },
39
17
  getParameters: function() {
40
18
  var n = [];
41
- return _LocationSearch._keyValuePairs.forEach(function(t) {
42
- n.push(t.split("=")[0])
43
- }), n
19
+ return t.forEach((function(t) {
20
+ n.push(t.split("=")[0]);
21
+ })), n;
44
22
  }
23
+ };
24
+ }, _LocationSearch = {
25
+ _keyValuePairs: [],
26
+ init: function() {
27
+ var t = window.location.search;
28
+ if (utils.isEmpty(t)) throw new Error("the [window.location.search] not empty!");
29
+ var n = t.length > 1 ? t.substring(1) : null;
30
+ return utils.isNull(n) || (_LocationSearch._keyValuePairs = [].slice.call(n.split("&"))),
31
+ this;
45
32
  },
46
- LocationParam = {
47
- parse: function(t) {
48
- var n, e, i, r, o;
49
- t = t || window.location.search;
50
- var a, c = {};
51
- if (!utils.isEmpty(t) && 1 < t.length)
52
- for (r = 0, o = (a = t.slice(1 + t.indexOf("?"), t.length).split("&")).length; r < o; r++) n = (e = (e = a[r]).split("="))[0], i = e[1], n in c ? (utils.isArray(c[n]) || (c[n] = [c[n]]), c[n].push(decodeURIComponent(i))) : c[n] = decodeURIComponent(i);
53
- return c
54
- },
55
- paramSearch: function(t, n) {
56
- if (utils.isUndefined(n) || utils.isNull(n)) {
57
- if (n = window.location.search, utils.isUndefined(t) || utils.isNull(t)) {
58
- for (var e = n.substr(1, n.length - 1).split("&"), i = {}, r = 0; r < e.length; r++) {
59
- var o = e[r].split("=");
60
- 1 === o.length ? i[o[0]] = "" : 2 === o.length ? i[o[0]] = decodeURIComponent(o[1]) : console.log("there is something wrong when use [paramSearch]!")
61
- }
62
- return i
63
- }
64
- try {
65
- var a = new RegExp(t + "=([^&]+)?");
66
- return decodeURIComponent(n.match(a)[1])
67
- } catch (t) {
68
- return null
33
+ getValue: function(t) {
34
+ _LocationSearch._keyValuePairs.forEach((function(n) {
35
+ var e = n.split("=");
36
+ if (e[0] === t) return e[1];
37
+ }));
38
+ },
39
+ getParameters: function() {
40
+ var t = [];
41
+ return _LocationSearch._keyValuePairs.forEach((function(n) {
42
+ t.push(n.split("=")[0]);
43
+ })), t;
44
+ }
45
+ }, LocationParam = {
46
+ parse: function(t) {
47
+ var n, e, i, r, o;
48
+ t || (t = window.location.search);
49
+ var a = {}, c = [];
50
+ if (!utils.isEmpty(t) && t.length > 1) for (r = 0, o = (c = t.slice(1 + t.indexOf("?"), t.length).split("&")).length; r < o; r++) n = (e = (e = c[r]).split("="))[0],
51
+ i = e[1], n in a ? (utils.isArray(a[n]) || (a[n] = [ a[n] ]), a[n].push(decodeURIComponent(i))) : a[n] = decodeURIComponent(i);
52
+ return a;
53
+ },
54
+ paramSearch: function(t, n) {
55
+ if (utils.isUndefined(n) || utils.isNull(n)) {
56
+ if (n = window.location.search, utils.isUndefined(t) || utils.isNull(t)) {
57
+ for (var e = n.substr(1, n.length - 1).split("&"), i = {}, r = 0; r < e.length; r++) {
58
+ var o = e[r].split("=");
59
+ 1 === o.length ? i[o[0]] = "" : 2 === o.length ? i[o[0]] = decodeURIComponent(o[1]) : console.log("there is something wrong when use [paramSearch]!");
69
60
  }
61
+ return i;
70
62
  }
71
- },
72
- getLocationParams: function() {
73
- var t, n, e = {},
74
- i = window.location.href;
75
- if (!utils.isEmpty(i)) {
76
- var r = i.indexOf("?");
77
- if (r < -1) console.log("the location.href is invalid!");
78
- else
79
- for (var o = (i = i.substr(r + 1)).split("&"), a = 0; a < o.length; a++) 0 < (r = o[a].indexOf("=")) && (t = o[a].substring(0, r), n = o[a].substr(r + 1), e[t] = decodeURIComponent(n))
63
+ try {
64
+ var a = new RegExp(t + "=([^&]+)?");
65
+ return decodeURIComponent(n.match(a)[1]);
66
+ } catch (t) {
67
+ return null;
80
68
  }
81
- return e
82
- },
83
- getLocationParamByName: function(t) {
84
- var n = new RegExp("(^|&)" + t + "=([^&]*)(&|$)"),
85
- e = window.location.search.substr(1).match(n);
86
- return null != e ? decodeURIComponent(e[2]) : null
87
- },
88
- getParameter: function(t, n) {
89
- var e = new RegExp("(\\?|#|&)" + n + "=([^&#]*)(&|#|$)"),
90
- i = t.match(e);
91
- return i ? i[2] : ""
92
- },
93
- extractParam: function(t, n) {
94
- var e = new RegExp("(^|&?)".concat(n, "=([^&]*)(&|$)"), "i"),
95
- i = t.substr(1).match(e);
96
- return utils.isNil(i) ? null : decodeURIComponent(i[2])
97
- },
98
- completeParam: function(e, t) {
99
- t = t || window.location.href;
100
- var n = (Object.keys(e) || []).reduce(function(t, n) {
101
- return t += "&".concat(n, "=").concat(e[n])
102
- }, "");
103
- return n ? (n = n.slice(1), -1 !== t.indexOf("?") ? t.endsWith("?") ? "".concat(t).concat(n) : "".concat(t, "&").concat(n) : "".concat(t, "?").concat(n)) : t
104
- },
105
- LocationSearch: _LocationSearch,
106
- LSFN: _LSFN
107
- };
108
- module.exports = LocationParam;
69
+ }
70
+ },
71
+ getLocationParams: function() {
72
+ var t, n, e = {}, i = window.location.href;
73
+ if (!utils.isEmpty(i)) {
74
+ var r = i.indexOf("?");
75
+ if (r < -1) console.log("the location.href is invalid!"); else for (var o = (i = i.substr(r + 1)).split("&"), a = 0; a < o.length; a++) (r = o[a].indexOf("=")) > 0 && (t = o[a].substring(0, r),
76
+ n = o[a].substr(r + 1), e[t] = decodeURIComponent(n));
77
+ }
78
+ return e;
79
+ },
80
+ getLocationParamByName: function(t) {
81
+ var n = new RegExp("(^|&)" + t + "=([^&]*)(&|$)"), e = window.location.search.substr(1).match(n);
82
+ return null != e ? decodeURIComponent(e[2]) : null;
83
+ },
84
+ getParameter: function(t, n) {
85
+ var e = new RegExp("(\\?|#|&)" + n + "=([^&#]*)(&|#|$)"), i = t.match(e);
86
+ return i ? i[2] : "";
87
+ },
88
+ extractParam: function(t, n) {
89
+ var e = new RegExp("(^|&?)".concat(n, "=([^&]*)(&|$)"), "i"), i = t.substr(1).match(e);
90
+ return utils.isNil(i) ? null : decodeURIComponent(i[2]);
91
+ },
92
+ completeParam: function(t, n) {
93
+ n || (n = window.location.href);
94
+ var e = (Object.keys(t) || []).reduce((function(n, e) {
95
+ return n += "&".concat(e, "=").concat(t[e]);
96
+ }), "");
97
+ return e ? (e = e.slice(1), -1 !== n.indexOf("?") ? n.endsWith("?") ? "".concat(n).concat(e) : "".concat(n, "&").concat(e) : "".concat(n, "?").concat(e)) : n;
98
+ },
99
+ LocationSearch: _LocationSearch,
100
+ LSFN: _LSFN
101
+ };
102
+
103
+ module.exports = LocationParam;
package/lib/log.js CHANGED
@@ -1,38 +1,32 @@
1
1
  "use strict";
2
- var Logger = function() {
3
- var r = this,
4
- o = 0,
5
- i = 1,
6
- t = 2,
7
- n = 3,
8
- s = 4,
9
- g = 5,
10
- l = ["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"];
11
2
 
12
- function c(o, i) {
13
- var t = [];
14
- for (var n in t.push(o), i) t.push(i[n]);
15
- r.log.apply(r, t)
3
+ var Logger = function() {
4
+ var o = this, i = 0, t = 1, n = 2, r = 3, s = 4, g = 5, l = [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL" ];
5
+ function c(i, t) {
6
+ var n = [];
7
+ for (var r in n.push(i), t) n.push(t[r]);
8
+ o.log.apply(o, n);
16
9
  }
17
10
  this.log = function() {
18
- var o = (i = arguments[0]) === s,
19
- i = arguments[0] = "[" + l[i] + "] ";
20
- if (window.LogConfig && window.LogConfig.isDebug && (console.log.apply(console, arguments), o)) try {
21
- var t = (t = Array.prototype.slice.call(arguments)).slice(1);
22
- throw new Error(t.join(","))
11
+ var o = arguments[0], i = o === s;
12
+ if (o = arguments[0] = "[" + l[o] + "] ", window.LogConfig && window.LogConfig.isDebug && (console.log.apply(console, arguments),
13
+ i)) try {
14
+ var t = Array.prototype.slice.call(arguments);
15
+ throw t = t.slice(1), new Error(t.join(","));
23
16
  } catch (o) {}
24
17
  }, this.trace = function() {
25
- this.log && c(o, arguments)
18
+ this.log && c(i, arguments);
26
19
  }, this.debug = function() {
27
- this.log && c(i, arguments)
20
+ this.log && c(t, arguments);
28
21
  }, this.info = function() {
29
- this.log && c(t, arguments)
22
+ this.log && c(n, arguments);
30
23
  }, this.warn = function() {
31
- this.log && c(n, arguments)
24
+ this.log && c(r, arguments);
32
25
  }, this.error = function() {
33
- this.log && c(s, arguments)
26
+ this.log && c(s, arguments);
34
27
  }, this.fatal = function() {
35
- this.log && c(g, arguments)
36
- }
28
+ this.log && c(g, arguments);
29
+ };
37
30
  };
38
- module.exports = new Logger;
31
+
32
+ module.exports = new Logger;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+
3
+ var colorKeyWordsHexStr = {
4
+ aliceblue: "#f0f8ff",
5
+ antiquewhite: "#faebd7",
6
+ aqua: "#00ffff",
7
+ aquamarine: "#7fffd4",
8
+ azure: "#f0ffff",
9
+ beige: "#f5f5dc",
10
+ bisque: "#ffe4c4",
11
+ black: "#000000",
12
+ blanchedalmond: "#ffebcd",
13
+ blue: "#0000ff",
14
+ blueviolet: "#8a2be2",
15
+ brown: "#a52a2a",
16
+ burlywood: "#deb887",
17
+ cadetblue: "#5f9ea0",
18
+ chartreuse: "#7fff00",
19
+ chocolate: "#d2691e",
20
+ coral: "#ff7f50",
21
+ cornflowerblue: "#6495ed",
22
+ cornsilk: "#fff8dc",
23
+ crimson: "#dc143c",
24
+ cyan: "#00ffff",
25
+ darkblue: "#00008b",
26
+ darkcyan: "#008b8b",
27
+ darkgoldenrod: "#b8860b",
28
+ darkgray: "#a9a9a9",
29
+ darkgreen: "#006400",
30
+ darkgrey: "#a9a9a9",
31
+ darkkhaki: "#bdb76b",
32
+ darkmagenta: "#8b008b",
33
+ darkolivegreen: "#556b2f",
34
+ darkorange: "#ff8c00",
35
+ darkorchid: "#9932cc",
36
+ darkred: "#8b0000",
37
+ darksalmon: "#e9967a",
38
+ darkseagreen: "#8fbc8f",
39
+ darkslateblue: "#483d8b",
40
+ darkslategray: "#2f4f4f",
41
+ darkslategrey: "#2f4f4f",
42
+ darkturquoise: "#00ced1",
43
+ darkviolet: "#9400d3",
44
+ deeppink: "#ff1493",
45
+ deepskyblue: "#00bfff",
46
+ dimgray: "#696969",
47
+ dimgrey: "#696969",
48
+ dodgerblue: "#1e90ff",
49
+ firebrick: "#b22222",
50
+ floralwhite: "#fffaf0",
51
+ forestgreen: "#228b22",
52
+ fuchsia: "#ff00ff",
53
+ gainsboro: "#dcdcdc",
54
+ ghostwhite: "#f8f8ff",
55
+ gold: "#ffd700",
56
+ goldenrod: "#daa520",
57
+ gray: "#808080",
58
+ green: "#008000",
59
+ greenyellow: "#adff2f",
60
+ grey: "#808080",
61
+ honeydew: "#f0fff0",
62
+ hotpink: "#ff69b4",
63
+ indianred: "#cd5c5c",
64
+ indigo: "#4b0082",
65
+ ivory: "#fffff0",
66
+ khaki: "#f0e68c",
67
+ lavender: "#e6e6fa",
68
+ lavenderblush: "#fff0f5",
69
+ lawngreen: "#7cfc00",
70
+ lemonchiffon: "#fffacd",
71
+ lightblue: "#add8e6",
72
+ lightcoral: "#f08080",
73
+ lightcyan: "#e0ffff",
74
+ lightgoldenrodyellow: "#fafad2",
75
+ lightgray: "#d3d3d3",
76
+ lightgreen: "#90ee90",
77
+ lightgrey: "#d3d3d3",
78
+ lightpink: "#ffb6c1",
79
+ lightsalmon: "#ffa07a",
80
+ lightseagreen: "#20b2aa",
81
+ lightskyblue: "#87cefa",
82
+ lightslategray: "#778899",
83
+ lightslategrey: "#778899",
84
+ lightsteelblue: "#b0c4de",
85
+ lightyellow: "#ffffe0",
86
+ lime: "#00ff00",
87
+ limegreen: "#32cd32",
88
+ linen: "#faf0e6",
89
+ magenta: "#ff00ff",
90
+ maroon: "#800000",
91
+ mediumaquamarine: "#66cdaa",
92
+ mediumblue: "#0000cd",
93
+ mediumorchid: "#ba55d3",
94
+ mediumpurple: "#9370db",
95
+ mediumseagreen: "#3cb371",
96
+ mediumslateblue: "#7b68ee",
97
+ mediumspringgreen: "#00fa9a",
98
+ mediumturquoise: "#48d1cc",
99
+ mediumvioletred: "#c71585",
100
+ midnightblue: "#191970",
101
+ mintcream: "#f5fffa",
102
+ mistyrose: "#ffe4e1",
103
+ moccasin: "#ffe4b5",
104
+ navajowhite: "#ffdead",
105
+ navy: "#000080",
106
+ oldlace: "#fdf5e6",
107
+ olive: "#808000",
108
+ olivedrab: "#6b8e23",
109
+ orange: "#ffa500",
110
+ orangered: "#ff4500",
111
+ orchid: "#da70d6",
112
+ palegoldenrod: "#eee8aa",
113
+ palegreen: "#98fb98",
114
+ paleturquoise: "#afeeee",
115
+ palevioletred: "#db7093",
116
+ papayawhip: "#ffefd5",
117
+ peachpuff: "#ffdab9",
118
+ peru: "#cd853f",
119
+ pink: "#ffc0cb",
120
+ plum: "#dda0dd",
121
+ powderblue: "#b0e0e6",
122
+ purple: "#800080",
123
+ rebeccapurple: "#663399",
124
+ red: "#ff0000",
125
+ rosybrown: "#bc8f8f",
126
+ royalblue: "#4169e1",
127
+ saddlebrown: "#8b4513",
128
+ salmon: "#fa8072",
129
+ sandybrown: "#f4a460",
130
+ seagreen: "#2e8b57",
131
+ seashell: "#fff5ee",
132
+ sienna: "#a0522d",
133
+ silver: "#c0c0c0",
134
+ skyblue: "#87ceeb",
135
+ slateblue: "#6a5acd",
136
+ slategray: "#708090",
137
+ slategrey: "#708090",
138
+ snow: "#fffafa",
139
+ springgreen: "#00ff7f",
140
+ steelblue: "#4682b4",
141
+ tan: "#d2b48c",
142
+ teal: "#008080",
143
+ thistle: "#d8bfd8",
144
+ tomato: "#ff6347",
145
+ turquoise: "#40e0d0",
146
+ violet: "#ee82ee",
147
+ wheat: "#f5deb3",
148
+ white: "#ffffff",
149
+ whitesmoke: "#f5f5f5",
150
+ yellow: "#ffff00",
151
+ yellowgreen: "#9acd32"
152
+ };
153
+
154
+ module.exports = colorKeyWordsHexStr;
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
+
2
3
  var pow = function(t) {
3
- return Math.pow(10, t)
4
+ return Math.pow(10, t);
4
5
  };
6
+
5
7
  module.exports = function(t, r) {
6
8
  var n, o;
7
9
  try {
8
- n = t.toString().split(".")[1].length
10
+ n = t.toString().split(".")[1].length;
9
11
  } catch (t) {
10
- n = 0
12
+ n = 0;
11
13
  }
12
14
  try {
13
- o = r.toString().split(".")[1].length
15
+ o = r.toString().split(".")[1].length;
14
16
  } catch (t) {
15
- o = 0
17
+ o = 0;
16
18
  }
17
19
  var a = pow(Math.max(n, o));
18
- return Number((t * a + r * a) / a)
19
- };
20
+ return Number((t * a + r * a) / a);
21
+ };
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
+
2
3
  module.exports = function(r) {
3
- var e = ["角", "分", "厘"],
4
- a = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"],
5
- o = [
6
- ["元", "万", "亿"],
7
- ["", "拾", "佰", "仟"]
8
- ],
9
- t = r < 0 ? "欠人民币" : "人民币";
4
+ var e = [ "角", "分", "厘" ], a = [ "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" ], o = [ [ "元", "万", "亿" ], [ "", "拾", "佰", "仟" ] ], t = r < 0 ? "欠人民币" : "人民币";
10
5
  r = Math.abs(r);
11
6
  for (var l = "", h = 0; h < e.length; h++) l += (a[Math.floor(10 * r * Math.pow(10, h)) % 10] + e[h]).replace(/零./, "");
12
7
  l = l || "整", r = Math.floor(r);
13
- for (h = 0; h < o[0].length && 0 < r; h++) {
14
- for (var f = "", c = 0; c < o[1].length && 0 < r; c++) f = a[r % 10] + o[1][c] + f, r = Math.floor(r / 10);
15
- l = f + o[0][h] + l
8
+ for (h = 0; h < o[0].length && r > 0; h++) {
9
+ for (var f = "", c = 0; c < o[1].length && r > 0; c++) f = a[r % 10] + o[1][c] + f,
10
+ r = Math.floor(r / 10);
11
+ l = f + o[0][h] + l;
16
12
  }
17
- return t + l.replace(/(零.)*零元/, "元").replace(/(零.)+/g, "零").replace(/^整$/, "零元整")
18
- };
13
+ return t + l.replace(/(零.)*零元/, "元").replace(/(零.)+/g, "零").replace(/^整$/, "零元整");
14
+ };
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+
2
3
  var utils = require("./../utils");
3
- module.exports = function(t, i, e, r, o) {
4
- var s, l = 3 < arguments.length && void 0 !== r ? r : "$",
5
- n = 4 < arguments.length && void 0 !== o ? o : "";
6
- return !isNaN(parseFloat(t)) && isFinite(t) ? (t = Number(t), (s = (t = (utils.isNil(i) ? t : (Math.round(t * Math.pow(10, i)) / Math.pow(10, i)).toFixed(i)).toString()).split("."))[0] = s[0].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1" + (e || ",")), l + s.join(".") + n) : ""
7
- };
4
+
5
+ module.exports = function(t, i, e) {
6
+ var r, o = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : "$", s = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : "";
7
+ return !isNaN(parseFloat(t)) && isFinite(t) ? (t = Number(t), (r = (t = (utils.isNil(i) ? t : (Math.round(t * Math.pow(10, i)) / Math.pow(10, i)).toFixed(i)).toString()).split("."))[0] = r[0].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1" + (e || ",")),
8
+ o + r.join(".") + s) : "";
9
+ };