amos-apptool 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_clone.js +72 -0
- package/esm/_deepCopy.js +27 -0
- package/esm/_deepEqual.js +7 -0
- package/esm/_fastDeepEqual.js +27 -0
- package/esm/_forOwn.js +11 -0
- package/esm/_isnode.js +3 -0
- package/esm/_omit.js +13 -0
- package/esm/_parseJson.js +9 -0
- package/esm/_pick.js +12 -0
- package/esm/_pickBy.js +14 -0
- package/esm/_queue.js +68 -0
- package/esm/_shallowCopy.js +57 -0
- package/esm/_stringify.js +12 -0
- package/esm/_trim.js +9 -0
- package/esm/_typeOfList.js +25 -0
- package/esm/_uuids.js +54 -0
- package/esm/encrypt/_base64.js +35 -0
- package/esm/encrypt/_md5.js +124 -0
- package/esm/encrypt/des.js +552 -0
- package/esm/index.js +73 -0
- package/esm/math/_keyColor.js +154 -0
- package/esm/math/addition.js +17 -0
- package/esm/math/amountCase.js +13 -0
- package/esm/math/coinFormat.js +7 -0
- package/esm/math/colorUtil.js +259 -0
- package/esm/math/dateTime.js +140 -0
- package/esm/math/divide.js +13 -0
- package/esm/math/mul.js +19 -0
- package/esm/math/pwdStrength.js +5 -0
- package/esm/math/randomColor.js +27 -0
- package/esm/math/subtraction.js +17 -0
- package/esm/merged.js +8 -0
- package/esm/objectPath.js +118 -0
- package/esm/parseText.js +9 -0
- package/esm/pwdPolicy.js +48 -0
- package/esm/random.js +29 -0
- package/esm/shallowEqual.js +24 -0
- package/esm/strUtils.js +88 -0
- package/esm/url/encodeUrl.js +8 -0
- package/esm/url/restfulUrl.js +7 -0
- package/esm/utils.js +347 -0
- package/package.json +4 -5
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const colorKeyWordsHexStr = {
|
|
2
|
+
aliceblue: "#f0f8ff",
|
|
3
|
+
antiquewhite: "#faebd7",
|
|
4
|
+
aqua: "#00ffff",
|
|
5
|
+
aquamarine: "#7fffd4",
|
|
6
|
+
azure: "#f0ffff",
|
|
7
|
+
beige: "#f5f5dc",
|
|
8
|
+
bisque: "#ffe4c4",
|
|
9
|
+
black: "#000000",
|
|
10
|
+
blanchedalmond: "#ffebcd",
|
|
11
|
+
blue: "#0000ff",
|
|
12
|
+
blueviolet: "#8a2be2",
|
|
13
|
+
brown: "#a52a2a",
|
|
14
|
+
burlywood: "#deb887",
|
|
15
|
+
cadetblue: "#5f9ea0",
|
|
16
|
+
chartreuse: "#7fff00",
|
|
17
|
+
chocolate: "#d2691e",
|
|
18
|
+
coral: "#ff7f50",
|
|
19
|
+
cornflowerblue: "#6495ed",
|
|
20
|
+
cornsilk: "#fff8dc",
|
|
21
|
+
crimson: "#dc143c",
|
|
22
|
+
cyan: "#00ffff",
|
|
23
|
+
darkblue: "#00008b",
|
|
24
|
+
darkcyan: "#008b8b",
|
|
25
|
+
darkgoldenrod: "#b8860b",
|
|
26
|
+
darkgray: "#a9a9a9",
|
|
27
|
+
darkgreen: "#006400",
|
|
28
|
+
darkgrey: "#a9a9a9",
|
|
29
|
+
darkkhaki: "#bdb76b",
|
|
30
|
+
darkmagenta: "#8b008b",
|
|
31
|
+
darkolivegreen: "#556b2f",
|
|
32
|
+
darkorange: "#ff8c00",
|
|
33
|
+
darkorchid: "#9932cc",
|
|
34
|
+
darkred: "#8b0000",
|
|
35
|
+
darksalmon: "#e9967a",
|
|
36
|
+
darkseagreen: "#8fbc8f",
|
|
37
|
+
darkslateblue: "#483d8b",
|
|
38
|
+
darkslategray: "#2f4f4f",
|
|
39
|
+
darkslategrey: "#2f4f4f",
|
|
40
|
+
darkturquoise: "#00ced1",
|
|
41
|
+
darkviolet: "#9400d3",
|
|
42
|
+
deeppink: "#ff1493",
|
|
43
|
+
deepskyblue: "#00bfff",
|
|
44
|
+
dimgray: "#696969",
|
|
45
|
+
dimgrey: "#696969",
|
|
46
|
+
dodgerblue: "#1e90ff",
|
|
47
|
+
firebrick: "#b22222",
|
|
48
|
+
floralwhite: "#fffaf0",
|
|
49
|
+
forestgreen: "#228b22",
|
|
50
|
+
fuchsia: "#ff00ff",
|
|
51
|
+
gainsboro: "#dcdcdc",
|
|
52
|
+
ghostwhite: "#f8f8ff",
|
|
53
|
+
gold: "#ffd700",
|
|
54
|
+
goldenrod: "#daa520",
|
|
55
|
+
gray: "#808080",
|
|
56
|
+
green: "#008000",
|
|
57
|
+
greenyellow: "#adff2f",
|
|
58
|
+
grey: "#808080",
|
|
59
|
+
honeydew: "#f0fff0",
|
|
60
|
+
hotpink: "#ff69b4",
|
|
61
|
+
indianred: "#cd5c5c",
|
|
62
|
+
indigo: "#4b0082",
|
|
63
|
+
ivory: "#fffff0",
|
|
64
|
+
khaki: "#f0e68c",
|
|
65
|
+
lavender: "#e6e6fa",
|
|
66
|
+
lavenderblush: "#fff0f5",
|
|
67
|
+
lawngreen: "#7cfc00",
|
|
68
|
+
lemonchiffon: "#fffacd",
|
|
69
|
+
lightblue: "#add8e6",
|
|
70
|
+
lightcoral: "#f08080",
|
|
71
|
+
lightcyan: "#e0ffff",
|
|
72
|
+
lightgoldenrodyellow: "#fafad2",
|
|
73
|
+
lightgray: "#d3d3d3",
|
|
74
|
+
lightgreen: "#90ee90",
|
|
75
|
+
lightgrey: "#d3d3d3",
|
|
76
|
+
lightpink: "#ffb6c1",
|
|
77
|
+
lightsalmon: "#ffa07a",
|
|
78
|
+
lightseagreen: "#20b2aa",
|
|
79
|
+
lightskyblue: "#87cefa",
|
|
80
|
+
lightslategray: "#778899",
|
|
81
|
+
lightslategrey: "#778899",
|
|
82
|
+
lightsteelblue: "#b0c4de",
|
|
83
|
+
lightyellow: "#ffffe0",
|
|
84
|
+
lime: "#00ff00",
|
|
85
|
+
limegreen: "#32cd32",
|
|
86
|
+
linen: "#faf0e6",
|
|
87
|
+
magenta: "#ff00ff",
|
|
88
|
+
maroon: "#800000",
|
|
89
|
+
mediumaquamarine: "#66cdaa",
|
|
90
|
+
mediumblue: "#0000cd",
|
|
91
|
+
mediumorchid: "#ba55d3",
|
|
92
|
+
mediumpurple: "#9370db",
|
|
93
|
+
mediumseagreen: "#3cb371",
|
|
94
|
+
mediumslateblue: "#7b68ee",
|
|
95
|
+
mediumspringgreen: "#00fa9a",
|
|
96
|
+
mediumturquoise: "#48d1cc",
|
|
97
|
+
mediumvioletred: "#c71585",
|
|
98
|
+
midnightblue: "#191970",
|
|
99
|
+
mintcream: "#f5fffa",
|
|
100
|
+
mistyrose: "#ffe4e1",
|
|
101
|
+
moccasin: "#ffe4b5",
|
|
102
|
+
navajowhite: "#ffdead",
|
|
103
|
+
navy: "#000080",
|
|
104
|
+
oldlace: "#fdf5e6",
|
|
105
|
+
olive: "#808000",
|
|
106
|
+
olivedrab: "#6b8e23",
|
|
107
|
+
orange: "#ffa500",
|
|
108
|
+
orangered: "#ff4500",
|
|
109
|
+
orchid: "#da70d6",
|
|
110
|
+
palegoldenrod: "#eee8aa",
|
|
111
|
+
palegreen: "#98fb98",
|
|
112
|
+
paleturquoise: "#afeeee",
|
|
113
|
+
palevioletred: "#db7093",
|
|
114
|
+
papayawhip: "#ffefd5",
|
|
115
|
+
peachpuff: "#ffdab9",
|
|
116
|
+
peru: "#cd853f",
|
|
117
|
+
pink: "#ffc0cb",
|
|
118
|
+
plum: "#dda0dd",
|
|
119
|
+
powderblue: "#b0e0e6",
|
|
120
|
+
purple: "#800080",
|
|
121
|
+
rebeccapurple: "#663399",
|
|
122
|
+
red: "#ff0000",
|
|
123
|
+
rosybrown: "#bc8f8f",
|
|
124
|
+
royalblue: "#4169e1",
|
|
125
|
+
saddlebrown: "#8b4513",
|
|
126
|
+
salmon: "#fa8072",
|
|
127
|
+
sandybrown: "#f4a460",
|
|
128
|
+
seagreen: "#2e8b57",
|
|
129
|
+
seashell: "#fff5ee",
|
|
130
|
+
sienna: "#a0522d",
|
|
131
|
+
silver: "#c0c0c0",
|
|
132
|
+
skyblue: "#87ceeb",
|
|
133
|
+
slateblue: "#6a5acd",
|
|
134
|
+
slategray: "#708090",
|
|
135
|
+
slategrey: "#708090",
|
|
136
|
+
snow: "#fffafa",
|
|
137
|
+
springgreen: "#00ff7f",
|
|
138
|
+
steelblue: "#4682b4",
|
|
139
|
+
tan: "#d2b48c",
|
|
140
|
+
teal: "#008080",
|
|
141
|
+
thistle: "#d8bfd8",
|
|
142
|
+
tomato: "#ff6347",
|
|
143
|
+
turquoise: "#40e0d0",
|
|
144
|
+
violet: "#ee82ee",
|
|
145
|
+
wheat: "#f5deb3",
|
|
146
|
+
white: "#ffffff",
|
|
147
|
+
whitesmoke: "#f5f5f5",
|
|
148
|
+
yellow: "#ffff00",
|
|
149
|
+
yellowgreen: "#9acd32",
|
|
150
|
+
transparent: "rgba(0, 0, 0, 0)",
|
|
151
|
+
none: "rgba(0, 0, 0, 0)"
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default colorKeyWordsHexStr;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const pow = t => 10 ** t;
|
|
2
|
+
|
|
3
|
+
export default function accAddition(t, n) {
|
|
4
|
+
let c, o;
|
|
5
|
+
try {
|
|
6
|
+
c = t.toString().split(".")[1].length;
|
|
7
|
+
} catch (t) {
|
|
8
|
+
c = 0;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
o = n.toString().split(".")[1].length;
|
|
12
|
+
} catch (t) {
|
|
13
|
+
o = 0;
|
|
14
|
+
}
|
|
15
|
+
const r = pow(Math.max(c, o));
|
|
16
|
+
return Number((t * r + n * r) / r);
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function(r) {
|
|
2
|
+
var a = [ "角", "分", "厘" ], e = [ "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" ], t = [ [ "元", "万", "亿" ], [ "", "拾", "佰", "仟" ] ], l = r < 0 ? "欠人民币" : "人民币";
|
|
3
|
+
r = Math.abs(r);
|
|
4
|
+
var o = "";
|
|
5
|
+
for (let t = 0; t < a.length; t++) o += (e[Math.floor(10 * r * Math.pow(10, t)) % 10] + a[t]).replace(/零./, "");
|
|
6
|
+
o = o || "整", r = Math.floor(r);
|
|
7
|
+
for (var f = 0; f < t[0].length && r > 0; f++) {
|
|
8
|
+
for (var h = "", n = 0; n < t[1].length && r > 0; n++) h = e[r % 10] + t[1][n] + h,
|
|
9
|
+
r = Math.floor(r / 10);
|
|
10
|
+
o = h + t[0][f] + o;
|
|
11
|
+
}
|
|
12
|
+
return l + o.replace(/(零.)*零元/, "元").replace(/(零.)+/g, "零").replace(/^整$/, "零元整");
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import utils from "./../utils";
|
|
2
|
+
|
|
3
|
+
export default function coinFormat(t, i, o, r = "$", a = "") {
|
|
4
|
+
var e;
|
|
5
|
+
return !isNaN(parseFloat(t)) && isFinite(t) ? (t = Number(t), (e = (t = (utils.isNil(i) ? t : (Math.round(t * Math.pow(10, i)) / Math.pow(10, i)).toFixed(i)).toString()).split("."))[0] = e[0].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1" + (o || ",")),
|
|
6
|
+
r + e.join(".") + a) : "";
|
|
7
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import utils from "./../utils";
|
|
2
|
+
|
|
3
|
+
import colorKeyWordsHexStr from "./_keyColor";
|
|
4
|
+
|
|
5
|
+
var strRGBA = function(r) {
|
|
6
|
+
return r.a || 0 === r.a ? "rgba(" + r.r + "," + r.g + "," + r.b + "," + r.a + ")" : "rgb(" + r.r + "," + r.g + "," + r.b + ")";
|
|
7
|
+
}, colorRegex = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/, rgbaRegex = /(?:\(|\)|rgba?|RGBA?)*/g, toStringHexColor = function(r) {
|
|
8
|
+
if (/^(rgba?|RGBA?)/.test(r)) {
|
|
9
|
+
for (var e = r.replace(rgbaRegex, "").split(","), o = "#", t = 0; t < e.length; t++) if (3 === t) {
|
|
10
|
+
var n = Number(e[t]);
|
|
11
|
+
n < 1 && (o += n = n.toString(16).substring(2, 4));
|
|
12
|
+
} else {
|
|
13
|
+
var l = Number(e[t]).toString(16);
|
|
14
|
+
1 === l.length && (l = `0${l}`), o += l;
|
|
15
|
+
}
|
|
16
|
+
return 7 !== o.length && 9 !== o.length && (o = r), o;
|
|
17
|
+
}
|
|
18
|
+
if (!colorRegex.test(r)) return r;
|
|
19
|
+
var s = r.replace(/#/, "").split("");
|
|
20
|
+
if (6 === s.length) return r;
|
|
21
|
+
if (3 === s.length) {
|
|
22
|
+
for (var i = "#", a = 0; a < s.length; a += 1) i += s[a] + s[a];
|
|
23
|
+
return i;
|
|
24
|
+
}
|
|
25
|
+
}, toHexColor = function(r) {
|
|
26
|
+
if (utils.isNil(r)) return "";
|
|
27
|
+
if (isHexColor(r)) return r;
|
|
28
|
+
if (isKeyColor(r)) return colorKeyWordsHexStr[r];
|
|
29
|
+
if (!utils.isString(r)) return "";
|
|
30
|
+
var e = r;
|
|
31
|
+
r.indexOf("rgb") > -1 && (e = e.replace(rgbaRegex, ""));
|
|
32
|
+
for (var o = e.split(","), t = "#", n = 0; n < o.length; n++) if (n < 3) {
|
|
33
|
+
var l = Number(o[n]).toString(16);
|
|
34
|
+
1 === l.length && (l = `0${l}`), t += l;
|
|
35
|
+
}
|
|
36
|
+
return t.length > 7 && (t = r), t;
|
|
37
|
+
}, toRGBcolor = function(r) {
|
|
38
|
+
var e = r.toLowerCase();
|
|
39
|
+
if (e && colorRegex.test(e)) {
|
|
40
|
+
if (4 === e.length) {
|
|
41
|
+
for (var o = "#", t = 1; t < 4; t += 1) o += e.slice(t, t + 1).concat(e.slice(t, t + 1));
|
|
42
|
+
e = o;
|
|
43
|
+
}
|
|
44
|
+
for (var n = [], l = 1; l < 7; l += 2) n.push(parseInt("0x" + e.slice(l, l + 2)));
|
|
45
|
+
return "rgb(" + n.join(",") + ")";
|
|
46
|
+
}
|
|
47
|
+
return e;
|
|
48
|
+
}, transformColor = function(r) {
|
|
49
|
+
var e = /#([a-zA-Z0-9]{6})/.exec(r), o = "rgb(";
|
|
50
|
+
if (e && 2 == e.length) {
|
|
51
|
+
var t = e[1];
|
|
52
|
+
o += parseInt("0x" + t.substr(0, 2)) + ",", o += parseInt("0x" + t.substr(2, 2)) + ",",
|
|
53
|
+
o += parseInt("0x" + t.substr(4, 2)), o += ")";
|
|
54
|
+
} else o = "rgb(147, 147, 147)";
|
|
55
|
+
return o;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function isRgbColor(r) {
|
|
59
|
+
var e = r.replace(rgbaRegex, "").split(",");
|
|
60
|
+
return !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(r) && e.length >= 3;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isHexColor(r) {
|
|
64
|
+
return /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(r);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isKeyColor(r) {
|
|
68
|
+
return !!colorKeyWordsHexStr[r];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function keyColorToHex(r) {
|
|
72
|
+
return colorKeyWordsHexStr[r] || r;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function rgb2object(r) {
|
|
76
|
+
if (isRgbColor(r)) {
|
|
77
|
+
var e = r.replace(rgbaRegex, "").split(",");
|
|
78
|
+
if (3 == e.length) return {
|
|
79
|
+
r: e[0],
|
|
80
|
+
g: e[1],
|
|
81
|
+
b: e[2],
|
|
82
|
+
a: "1"
|
|
83
|
+
};
|
|
84
|
+
if (e.length > 3) return {
|
|
85
|
+
r: e[0],
|
|
86
|
+
g: e[1],
|
|
87
|
+
b: e[2],
|
|
88
|
+
a: e[3] || "1"
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
r: "0",
|
|
93
|
+
g: "0",
|
|
94
|
+
b: "0",
|
|
95
|
+
a: "1"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function objRGB2str(r) {
|
|
100
|
+
return utils.isObject(r) && utils.isKeyInObject([ "r", "g", "b" ], r) ? strRGBA(r) : strRGBA({
|
|
101
|
+
r: 0,
|
|
102
|
+
g: 0,
|
|
103
|
+
b: 0
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function gradientColor(r, e, o) {
|
|
108
|
+
var t = function(r) {
|
|
109
|
+
var e = /rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(r), o = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*/.exec(r), t = /#([a-zA-Z0-9]{6})/.exec(r), n = [];
|
|
110
|
+
if (e && 4 == e.length || o && 4 == o.length) n = e && 4 == e.length ? e : o; else {
|
|
111
|
+
if (!t || 2 != t.length) return null;
|
|
112
|
+
var l = t[1];
|
|
113
|
+
n.push(""), n.push(parseInt("0x" + l.substr(0, 2))), n.push(parseInt("0x" + l.substr(2, 2))),
|
|
114
|
+
n.push(parseInt("0x" + l.substr(4, 2)));
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
r: Number(n[1]),
|
|
118
|
+
g: Number(n[2]),
|
|
119
|
+
b: Number(n[3])
|
|
120
|
+
};
|
|
121
|
+
}, n = t(r.from), l = t(r.to), s = function(r, e, o) {
|
|
122
|
+
return Math.round(r + (e - r) * o / 100);
|
|
123
|
+
}, i = function(r, e) {
|
|
124
|
+
return null == e || e < 0 || "number" != typeof e ? r : (e = Math.round(e), Math.round(r * Math.pow(10, e)) / Math.pow(10, e));
|
|
125
|
+
};
|
|
126
|
+
return function(r) {
|
|
127
|
+
var t = o == e ? 0 : (r.value - e) / (o - e), a = s(n.r, l.r, 100 * i(t, 2)), u = s(n.g, l.g, 100 * i(t, 2)), g = s(n.b, l.b, 100 * i(t, 2));
|
|
128
|
+
return strRGBA({
|
|
129
|
+
r: a,
|
|
130
|
+
g: u,
|
|
131
|
+
b: g
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const alphaHexMap = {
|
|
137
|
+
"1.00": "FF",
|
|
138
|
+
.99: "FC",
|
|
139
|
+
.98: "FA",
|
|
140
|
+
.97: "F7",
|
|
141
|
+
.96: "F5",
|
|
142
|
+
.95: "F2",
|
|
143
|
+
.94: "F0",
|
|
144
|
+
.93: "ED",
|
|
145
|
+
.92: "EB",
|
|
146
|
+
.91: "E8",
|
|
147
|
+
"0.90": "E6",
|
|
148
|
+
.89: "E3",
|
|
149
|
+
.88: "E0",
|
|
150
|
+
.87: "DE",
|
|
151
|
+
.86: "DB",
|
|
152
|
+
.85: "D9",
|
|
153
|
+
.84: "D6",
|
|
154
|
+
.83: "D4",
|
|
155
|
+
.82: "D1",
|
|
156
|
+
.81: "CF",
|
|
157
|
+
"0.80": "CC",
|
|
158
|
+
.79: "C9",
|
|
159
|
+
.78: "C7",
|
|
160
|
+
.77: "C4",
|
|
161
|
+
.76: "C2",
|
|
162
|
+
.75: "BF",
|
|
163
|
+
.74: "BD",
|
|
164
|
+
.73: "BA",
|
|
165
|
+
.72: "B8",
|
|
166
|
+
.71: "B5",
|
|
167
|
+
"0.70": "B3",
|
|
168
|
+
.69: "B0",
|
|
169
|
+
.68: "AD",
|
|
170
|
+
.67: "AB",
|
|
171
|
+
.66: "A8",
|
|
172
|
+
.65: "A6",
|
|
173
|
+
.64: "A3",
|
|
174
|
+
.63: "A1",
|
|
175
|
+
.62: "9E",
|
|
176
|
+
.61: "9C",
|
|
177
|
+
"0.60": "99",
|
|
178
|
+
.59: "96",
|
|
179
|
+
.58: "94",
|
|
180
|
+
.57: "91",
|
|
181
|
+
.56: "8F",
|
|
182
|
+
.55: "8C",
|
|
183
|
+
.54: "8A",
|
|
184
|
+
.53: "87",
|
|
185
|
+
.52: "85",
|
|
186
|
+
.51: "82",
|
|
187
|
+
"0.50": "80",
|
|
188
|
+
.49: "7D",
|
|
189
|
+
.48: "7A",
|
|
190
|
+
.47: "78",
|
|
191
|
+
.46: "75",
|
|
192
|
+
.45: "73",
|
|
193
|
+
.44: "70",
|
|
194
|
+
.43: "6E",
|
|
195
|
+
.42: "6B",
|
|
196
|
+
.41: "69",
|
|
197
|
+
"0.40": "66",
|
|
198
|
+
.39: "63",
|
|
199
|
+
.38: "61",
|
|
200
|
+
.37: "5E",
|
|
201
|
+
.36: "5C",
|
|
202
|
+
.35: "59",
|
|
203
|
+
.34: "57",
|
|
204
|
+
.33: "54",
|
|
205
|
+
.32: "52",
|
|
206
|
+
.31: "4F",
|
|
207
|
+
"0.30": "4D",
|
|
208
|
+
.29: "4A",
|
|
209
|
+
.28: "47",
|
|
210
|
+
.27: "45",
|
|
211
|
+
.26: "42",
|
|
212
|
+
.25: "40",
|
|
213
|
+
.24: "3D",
|
|
214
|
+
.23: "3B",
|
|
215
|
+
.22: "38",
|
|
216
|
+
.21: "36",
|
|
217
|
+
"0.20": "33",
|
|
218
|
+
.19: "30",
|
|
219
|
+
.18: "2E",
|
|
220
|
+
.17: "2B",
|
|
221
|
+
.16: "29",
|
|
222
|
+
.15: "26",
|
|
223
|
+
.14: "24",
|
|
224
|
+
.13: "21",
|
|
225
|
+
.12: "1F",
|
|
226
|
+
.11: "1C",
|
|
227
|
+
"0.10": "1A",
|
|
228
|
+
.09: "17",
|
|
229
|
+
.08: "14",
|
|
230
|
+
.07: "12",
|
|
231
|
+
.06: "0F",
|
|
232
|
+
.05: "0D",
|
|
233
|
+
.04: "0A",
|
|
234
|
+
.03: "08",
|
|
235
|
+
.02: "05",
|
|
236
|
+
.01: "03",
|
|
237
|
+
"0.00": "00"
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
function toHexAlphaColor(r, e) {
|
|
241
|
+
return 1 === e ? r : void 0 !== e && e < 1 ? `${r}${alphaHexMap[e.toFixed(2)]}`.toLowerCase() : r;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const colorUtil = {
|
|
245
|
+
toStringHexColor: toStringHexColor,
|
|
246
|
+
toHexColor: toHexColor,
|
|
247
|
+
toRGBcolor: toRGBcolor,
|
|
248
|
+
transformColor: transformColor,
|
|
249
|
+
isHexColor: isHexColor,
|
|
250
|
+
isKeyColor: isKeyColor,
|
|
251
|
+
isRgbColor: isRgbColor,
|
|
252
|
+
rgb2object: rgb2object,
|
|
253
|
+
objRGB2str: objRGB2str,
|
|
254
|
+
keyColorToHex: keyColorToHex,
|
|
255
|
+
gradientColor: gradientColor,
|
|
256
|
+
toHexAlphaColor: toHexAlphaColor
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export default colorUtil;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import utils from "./../utils";
|
|
2
|
+
|
|
3
|
+
function isValidDate(e) {
|
|
4
|
+
return e instanceof Date && (e instanceof Date && !isNaN(e.getTime()));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const dateTime = {
|
|
8
|
+
formatDate(e, t) {
|
|
9
|
+
let r = null == e ? new Date : e;
|
|
10
|
+
if (utils.isNumber(r) && !utils.isString(r) && (r = Number(r)), r instanceof Date || (r = new Date(r)),
|
|
11
|
+
!isValidDate(r)) return e;
|
|
12
|
+
t = t || "yyyy-MM-dd HH:mm:ss";
|
|
13
|
+
const a = {
|
|
14
|
+
y: r.getFullYear(),
|
|
15
|
+
M: r.getMonth() + 1,
|
|
16
|
+
d: r.getDate(),
|
|
17
|
+
q: Math.floor((r.getMonth() + 3) / 3),
|
|
18
|
+
w: r.getDay(),
|
|
19
|
+
H: r.getHours(),
|
|
20
|
+
h: r.getHours() % 12 == 0 ? 12 : r.getHours() % 12,
|
|
21
|
+
m: r.getMinutes(),
|
|
22
|
+
s: r.getSeconds(),
|
|
23
|
+
S: r.getMilliseconds()
|
|
24
|
+
}, n = [ "天", "一", "二", "三", "四", "五", "六" ];
|
|
25
|
+
for (let e in a) t = t.replace(new RegExp(e + "+", "g"), function(t) {
|
|
26
|
+
let r = a[e] + "";
|
|
27
|
+
if ("w" == e) return (t.length > 2 ? "星期" : "周") + n[r];
|
|
28
|
+
for (let e = 0, a = r.length; e < t.length - a; e++) r = "0" + r;
|
|
29
|
+
return 1 == t.length ? r : r.substring(r.length - t.length);
|
|
30
|
+
});
|
|
31
|
+
return t;
|
|
32
|
+
},
|
|
33
|
+
formatDate2(e, t) {
|
|
34
|
+
if ("number" == typeof (e = null == e ? new Date : e) && (e = new Date(e)), "string" == typeof e) return e;
|
|
35
|
+
let r = {
|
|
36
|
+
"M+": e.getMonth() + 1,
|
|
37
|
+
"d+": e.getDate(),
|
|
38
|
+
"H+": e.getHours(),
|
|
39
|
+
"m+": e.getMinutes(),
|
|
40
|
+
"s+": e.getSeconds()
|
|
41
|
+
};
|
|
42
|
+
/(y+)/.test(t) && (t = t.replace(RegExp.$1, `${e.getFullYear()}`.substr(4 - RegExp.$1.length)));
|
|
43
|
+
for (let e in r) new RegExp(`(${e})`).test(t) && (t = t.replace(RegExp.$1, 1 === RegExp.$1.length ? r[e] : `00${r[e]}`.substr(`${r[e]}`.length)));
|
|
44
|
+
return t;
|
|
45
|
+
},
|
|
46
|
+
timetrans: e => (e = new Date(1e3 * e)).getFullYear() + "-" + ((e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1) + "-") + ((e.getDate() < 10 ? "0" + e.getDate() : e.getDate()) + " ") + ((e.getHours() < 10 ? "0" + e.getHours() : e.getHours()) + ":") + ((e.getMinutes() < 10 ? "0" + e.getMinutes() : e.getMinutes()) + ":") + (e.getSeconds() < 10 ? "0" + e.getSeconds() : e.getSeconds()),
|
|
47
|
+
formatDateToFriendly(e) {
|
|
48
|
+
e = "number" == typeof (e = e || new Date) ? new Date(e) : e;
|
|
49
|
+
var t = new Date;
|
|
50
|
+
if (t.getTime() - e.getTime() < 6e4) return "刚刚";
|
|
51
|
+
var r = this.formatDate(e, "yyyy年M月d日");
|
|
52
|
+
return r == this.formatDate(t, "yyyy年M月d日") ? this.formatDate(e, "HH:mm") : e.getFullYear() == t.getFullYear() ? this.formatDate(e, "M月d日") : r;
|
|
53
|
+
},
|
|
54
|
+
friendlyDate(e) {
|
|
55
|
+
var t = +new Date - e, r = 6e4, a = 36e5, n = 864e5, s = 30 * n, i = 12 * s;
|
|
56
|
+
return t >= i ? parseInt(t / i) + "年前" : t >= s ? parseInt(t / s) + "个月前" : t >= n ? parseInt(t / n) + "天前" : t >= a ? parseInt(t / a) + "小时前" : t >= r ? parseInt(t / r) + "分钟前" : t >= 1e3 ? "刚刚" : void 0;
|
|
57
|
+
},
|
|
58
|
+
formatDurationToFriendly: e => e < 60 ? e + "秒" : e < 3600 ? (e - e % 60) / 60 + "分" + e % 60 + "秒" : e < 86400 ? (e - e % 3600) / 60 / 60 + "小时" + Math.round(e % 3600 / 60) + "分" : (e / 60 / 60 / 24).toFixed(1) + "天",
|
|
59
|
+
formatTimeToFriendly(e) {
|
|
60
|
+
let t = Math.floor(e / 60);
|
|
61
|
+
t = t < 10 ? "0" + t : t;
|
|
62
|
+
let r = e % 60;
|
|
63
|
+
return r = r < 10 ? "0" + r : r, t + ":" + r;
|
|
64
|
+
},
|
|
65
|
+
isLeapYear: e => (void 0 === e && (e = new Date), e instanceof Date && (e = e.getFullYear()),
|
|
66
|
+
e % 4 == 0 && e % 100 != 0 || e % 400 == 0),
|
|
67
|
+
getMonthDays(e, t) {
|
|
68
|
+
let r, a;
|
|
69
|
+
null == e && (e = new Date), e instanceof Date ? (r = e.getFullYear(), a = e.getMonth()) : "number" == typeof e && (r = e,
|
|
70
|
+
a = t - 1);
|
|
71
|
+
let n = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
|
|
72
|
+
return 1 == a && this.isLeapYear(r) ? n[a] + 1 : n[a];
|
|
73
|
+
},
|
|
74
|
+
countDays(e, t) {
|
|
75
|
+
var r = "yyyy-MM-dd";
|
|
76
|
+
return e instanceof Date && t instanceof Date && (e = this.format(r, e), t = this.format(r, t)),
|
|
77
|
+
"string" == typeof e && "string" == typeof t ? (e = this.parseDate(e, r), t = this.parseDate(t, r),
|
|
78
|
+
(e.getTime() - t.getTime()) / 864e5) : (console.error("参数格式无效!"), 0);
|
|
79
|
+
},
|
|
80
|
+
parseDate(e, t) {
|
|
81
|
+
var r = {
|
|
82
|
+
y: 0,
|
|
83
|
+
M: 1,
|
|
84
|
+
d: 0,
|
|
85
|
+
H: 0,
|
|
86
|
+
h: 0,
|
|
87
|
+
m: 0,
|
|
88
|
+
s: 0,
|
|
89
|
+
S: 0
|
|
90
|
+
};
|
|
91
|
+
(t = t || "yyyy-MM-dd").replace(/([^yMdHmsS]*?)(([yMdHmsS])\3*)([^yMdHmsS]*?)/g, function(t, a, n, s, i, g, o) {
|
|
92
|
+
return e = e.replace(new RegExp(a + "(\\d{" + n.length + "})" + i), function(e, t) {
|
|
93
|
+
return r[s] = parseInt(t), "";
|
|
94
|
+
}), "";
|
|
95
|
+
}), r.M--;
|
|
96
|
+
var a = new Date(r.y, r.M, r.d, r.H, r.m, r.s);
|
|
97
|
+
return 0 !== r.S && a.setMilliseconds(r.S), a;
|
|
98
|
+
},
|
|
99
|
+
getEndTime(e) {
|
|
100
|
+
let t = new Date, r = new Date(e).getTime() - t.getTime(), a = 0, n = 0, s = 0, i = 0;
|
|
101
|
+
return r >= 0 && (a = Math.floor(r / 1e3 / 3600 / 24), n = Math.floor(r / 1e3 / 60 / 60 % 24),
|
|
102
|
+
s = Math.floor(r / 1e3 / 60 % 60), i = Math.floor(r / 1e3 % 60)), {
|
|
103
|
+
d: a,
|
|
104
|
+
h: n,
|
|
105
|
+
m: s,
|
|
106
|
+
s: i
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
getEndTimeStr: function(e) {
|
|
110
|
+
const {d: t, h: r, m: a, s: n} = this.getEndTime(e);
|
|
111
|
+
return "剩余时间" + t + "天 " + r + "小时 " + a + " 分钟" + n + " 秒";
|
|
112
|
+
},
|
|
113
|
+
getMonthOfDay(e) {
|
|
114
|
+
var t = new Date(e), r = t.getFullYear(), a = t.getMonth() + 1;
|
|
115
|
+
return 2 == a ? r % 4 == 0 && r % 100 == 0 && r % 400 == 0 || r % 4 == 0 && r % 100 != 0 ? 28 : 29 : 1 == a || 3 == a || 5 == a || 7 == a || 8 == a || 10 == a || 12 == a ? 31 : 30;
|
|
116
|
+
},
|
|
117
|
+
getYearOfDay(e) {
|
|
118
|
+
var t = this.getFirstDayOfYear(e), r = this.getLastDayOfYear(e), a = (new Date(r).getTime() - new Date(t).getTime()) / 1e3;
|
|
119
|
+
return Math.ceil(a / 86400);
|
|
120
|
+
},
|
|
121
|
+
getFirstDayOfYear: e => new Date(e).getFullYear() + "-01-01 00:00:00",
|
|
122
|
+
getLastDayOfYear(e) {
|
|
123
|
+
var t = new Date(e).getFullYear(), r = t + "-12-01 00:00:00";
|
|
124
|
+
return t + "-12-" + this.getMonthOfDay(r) + " 23:59:59";
|
|
125
|
+
},
|
|
126
|
+
getDayOfYear(e) {
|
|
127
|
+
var t = this.getFirstDayOfYear(e), r = (new Date(e).getTime() - new Date(t).getTime()) / 1e3;
|
|
128
|
+
return Math.ceil(r / 86400);
|
|
129
|
+
},
|
|
130
|
+
getDayOfYearWeek(e) {
|
|
131
|
+
var t = this.getDayOfYear(e);
|
|
132
|
+
return Math.ceil(t / 7);
|
|
133
|
+
},
|
|
134
|
+
timeFn(e, t = 1) {
|
|
135
|
+
var r = new Date(e.replace(/-/g, "/")), a = (new Date).getTime() - r.getTime(), n = Math.floor(a / 864e5), s = a % 864e5, i = Math.floor(s / 36e5), g = s % 36e5, o = Math.floor(g / 6e4), l = g % 6e4, u = Math.round(l / 1e3);
|
|
136
|
+
return t ? `相差${n}天${i}小时${o}分钟${u}秒` : `${a}时间差的毫秒数,${n}计算出相差天数,${s}计算天数后剩余的毫秒数,${i}计算出小时数,${o}计算相差分钟数,${u}计算相差秒数`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export default dateTime;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const pow = t => 10 ** t;
|
|
2
|
+
|
|
3
|
+
export default function accDivide(t, e, r = 0) {
|
|
4
|
+
let l = 0, c = 0, n = t.toString(), i = e.toString();
|
|
5
|
+
try {
|
|
6
|
+
l = n.split(".")[1].length;
|
|
7
|
+
} catch (t) {}
|
|
8
|
+
try {
|
|
9
|
+
c = i.split(".")[1].length;
|
|
10
|
+
} catch (t) {}
|
|
11
|
+
let o = Number(n.replace(".", "")) / Number(i.replace(".", "")) * pow(c - l);
|
|
12
|
+
return null != r && r > 0 && (o = o.toFixed(r)), Number(o);
|
|
13
|
+
}
|
package/esm/math/mul.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const pow = e => 10 ** e;
|
|
2
|
+
|
|
3
|
+
export default function accMul(e, t, r = 0) {
|
|
4
|
+
if (!parseInt(r) == r) return;
|
|
5
|
+
let c, o, p = 0, l = e.toString(), n = t.toString(), u = 0;
|
|
6
|
+
try {
|
|
7
|
+
u = l.split(".")[1].length || 0;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
u = 0;
|
|
10
|
+
}
|
|
11
|
+
p += u;
|
|
12
|
+
try {
|
|
13
|
+
c = n.split(".")[1].length || 0;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
c = 0;
|
|
16
|
+
}
|
|
17
|
+
return p += c, o = p > r ? Math.round(Number(l.replace(".", "")) * Number(n.replace(".", "")) / pow(p - r)) / pow(r) : p <= r ? (Number(l.replace(".", "")) * Number(n.replace(".", "")) / pow(p)).toFixed(r) : (e * t).toFixed(r),
|
|
18
|
+
Number(o);
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const randomColor = {
|
|
2
|
+
randomHexColor: function() {
|
|
3
|
+
return (~~(Math.random() * (1 << 24))).toString(16);
|
|
4
|
+
},
|
|
5
|
+
randomRgbColor: function() {
|
|
6
|
+
return "rgb(" + this._random(255) + "," + this._random(255) + "," + this._random(255) + ")";
|
|
7
|
+
},
|
|
8
|
+
randomRgbaColor: function(r) {
|
|
9
|
+
const o = r || this._randomAlpha();
|
|
10
|
+
return "rgba(" + this._random(255) + "," + this._random(255) + "," + this._random(255) + "," + o + ")";
|
|
11
|
+
},
|
|
12
|
+
_randomAlpha: function() {
|
|
13
|
+
return parseFloat(Math.random().toFixed(2));
|
|
14
|
+
},
|
|
15
|
+
_random: function(r) {
|
|
16
|
+
return Math.floor(Math.random() * r + 1);
|
|
17
|
+
},
|
|
18
|
+
randomHexColorStr: function() {
|
|
19
|
+
return "#" + Math.random().toString(16).substring(2).substr(0, 6);
|
|
20
|
+
},
|
|
21
|
+
randomHexAlphaColorStr: function() {
|
|
22
|
+
const r = Math.round(255 * this._randomAlpha()).toString(16);
|
|
23
|
+
return this.randomHexColorStr() + r;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default randomColor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const pow = t => 10 ** t;
|
|
2
|
+
|
|
3
|
+
export default function accSubtraction(t, c) {
|
|
4
|
+
let n, o;
|
|
5
|
+
try {
|
|
6
|
+
n = t.toString().split(".")[1].length;
|
|
7
|
+
} catch (t) {
|
|
8
|
+
n = 0;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
o = c.toString().split(".")[1].length;
|
|
12
|
+
} catch (t) {
|
|
13
|
+
o = 0;
|
|
14
|
+
}
|
|
15
|
+
const r = pow(Math.max(n, o)), e = ((t * r - c * r) / r).toFixed(n >= o ? n : o);
|
|
16
|
+
return Number(e);
|
|
17
|
+
}
|
package/esm/merged.js
ADDED