amos-tool 1.4.9 → 1.4.12

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 (35) hide show
  1. package/docs/Logger.html +347 -0
  2. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  3. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  4. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  5. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  6. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  10. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  11. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  12. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  13. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  14. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  20. package/docs/global.html +15490 -0
  21. package/docs/index.html +794 -0
  22. package/docs/scripts/collapse.js +20 -0
  23. package/docs/scripts/linenumber.js +25 -0
  24. package/docs/scripts/nav.js +12 -0
  25. package/docs/scripts/polyfill.js +4 -0
  26. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  27. package/docs/scripts/prettify/lang-css.js +2 -0
  28. package/docs/scripts/prettify/prettify.js +28 -0
  29. package/docs/scripts/search.js +83 -0
  30. package/docs/styles/jsdoc.css +765 -0
  31. package/docs/styles/prettify.css +79 -0
  32. package/index.d.ts +40 -0
  33. package/lib/completeUnit.js +3 -4
  34. package/lib/utils.js +20 -0
  35. package/package.json +1 -1
@@ -0,0 +1,79 @@
1
+ .pln {
2
+ color: #ddd;
3
+ }
4
+
5
+ /* string content */
6
+ .str {
7
+ color: #61ce3c;
8
+ }
9
+
10
+ /* a keyword */
11
+ .kwd {
12
+ color: #fbde2d;
13
+ }
14
+
15
+ /* a comment */
16
+ .com {
17
+ color: #aeaeae;
18
+ }
19
+
20
+ /* a type name */
21
+ .typ {
22
+ color: #8da6ce;
23
+ }
24
+
25
+ /* a literal value */
26
+ .lit {
27
+ color: #fbde2d;
28
+ }
29
+
30
+ /* punctuation */
31
+ .pun {
32
+ color: #ddd;
33
+ }
34
+
35
+ /* lisp open bracket */
36
+ .opn {
37
+ color: #000000;
38
+ }
39
+
40
+ /* lisp close bracket */
41
+ .clo {
42
+ color: #000000;
43
+ }
44
+
45
+ /* a markup tag name */
46
+ .tag {
47
+ color: #8da6ce;
48
+ }
49
+
50
+ /* a markup attribute name */
51
+ .atn {
52
+ color: #fbde2d;
53
+ }
54
+
55
+ /* a markup attribute value */
56
+ .atv {
57
+ color: #ddd;
58
+ }
59
+
60
+ /* a declaration */
61
+ .dec {
62
+ color: #EF5050;
63
+ }
64
+
65
+ /* a variable name */
66
+ .var {
67
+ color: #c82829;
68
+ }
69
+
70
+ /* a function name */
71
+ .fun {
72
+ color: #4271ae;
73
+ }
74
+
75
+ /* Specify class=linenums on a pre to get line numbering */
76
+ ol.linenums {
77
+ margin-top: 0;
78
+ margin-bottom: 0;
79
+ }
package/index.d.ts CHANGED
@@ -927,10 +927,18 @@ declare namespace utils {
927
927
  export function stringIsJson(value: any): boolean;
928
928
  /**
929
929
  * 判断key是否在object内
930
+ * (采用 in 判断,继承属性均会判断)
930
931
  * @param keys
931
932
  * @param obj
932
933
  */
933
934
  export function isKeyInObject(keys: string | string[], obj: any): boolean;
935
+ /**
936
+ * 判断key是否在object内
937
+ * (采用 hasOwnProperty 判断,继承属性不会判断)
938
+ * @param keys
939
+ * @param obj
940
+ */
941
+ export function isOwnKeyInObject(keys: string | string[], obj: any): boolean;
934
942
  export function simpleEqual(objA: object, objB: object): boolean;
935
943
  /**
936
944
  * 判断是一个 image 的路径
@@ -953,6 +961,38 @@ declare namespace utils {
953
961
  */
954
962
  export function encodeNumber(number: Number, start?: number, len?: number, sign?: string): String;
955
963
 
964
+ /**
965
+ * 获取扩展名
966
+ *
967
+ * 可快速使用 `filePath.split('.').pop();` 获取扩展名
968
+ * @param filePath
969
+ * @return {String} ext
970
+ * @example
971
+ * getFileExtension('a.png'); // png
972
+ * getFileExtension('a/a/a.png'); // png
973
+ * getFileExtension('a.a.a.png.jpg'); // jpg
974
+ * getFileExtension('a'); // ''
975
+ */
976
+ export function getFileExtension(filePath: string): String;
977
+
978
+ /**
979
+ * 将指定 size 中的数据,转化为 byte
980
+ * - 默认不区分大小写, mb/MB/Mb 均表示 mb
981
+ * - 默认去除内部所有空格, 1024 MB -> 1024mb
982
+ * - 无单位或者 number 类型,将直接转化为 number值,默认当 byte 处理
983
+ * @param size 带有单位的 size,不带单位时,直接返回该值
984
+ * @returns byte
985
+ * @example
986
+ * fileSizeToByte('1kb'); // 1024
987
+ * fileSizeToByte('1mb'); // 1048576
988
+ * fileSizeToByte('1MB'); // 1048576
989
+ * fileSizeToByte('1gb'); // 1073741824
990
+ * fileSizeToByte('1tb'); // 1099511627776
991
+ * fileSizeToByte('123'); // 123
992
+ * fileSizeToByte(123); // 123
993
+ */
994
+ export function fileSizeToByte(size: string): String;
995
+
956
996
  export function some(arr: Array<any>, fun: Function /*, thisArg */): boolean;
957
997
  export function every(arr: Array<any>, callbackfn: Function, thisArg): boolean;
958
998
  export function reduce(arr: Array<any>, callback: Function /*, initialValue*/);
@@ -2,14 +2,13 @@
2
2
 
3
3
  var utils = require("./utils");
4
4
 
5
- function completeUnit(e) {
6
- var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "px";
7
- return utils.isString(e) || (e += ""), e.endsWith(t) ? e : "".concat(e).concat(t);
5
+ function completeUnit(e, t) {
6
+ return utils.isString(e) || (e += ""), utils.isNumber(e) ? (t || (t = "px"), e.endsWith(t) ? e : "".concat(e).concat(t)) : e;
8
7
  }
9
8
 
10
9
  function toPixel(e) {
11
10
  var t = e;
12
- return e && (utils.isNumber(e) ? t = completeUnit(Number(e)) : utils.isString(e) && e.endsWith("%") ? t = completeUnit(Number(e.replace("%", "")), "%") : utils.isString(e) && e.endsWith("px") ? t = completeUnit(Number(e.replace("px", "")), "px") : utils.isString(e) && e.endsWith("vh") ? t = completeUnit(Number(e.replace("vh", "")), "vh") : utils.isString(e) && e.endsWith("vw") ? t = completeUnit(Number(e.replace("vw", "")), "vw") : utils.isString(e) && e.endsWith("rem") ? t = completeUnit(Number(e.replace("rem", "")), "rem") : utils.isString(e) && e.endsWith("em") && (t = completeUnit(Number(e.replace("em", "")), "em"))),
11
+ return e && (utils.isNumber(e) ? t = completeUnit(Number(e)) : utils.isString(e) && (e.endsWith("%") ? t = completeUnit(Number(e.replace("%", "")), "%") : e.endsWith("px") ? t = completeUnit(Number(e.replace("px", "")), "px") : e.endsWith("vh") ? t = completeUnit(Number(e.replace("vh", "")), "vh") : e.endsWith("vw") ? t = completeUnit(Number(e.replace("vw", "")), "vw") : e.endsWith("rem") ? t = completeUnit(Number(e.replace("rem", "")), "rem") : e.endsWith("em") && (t = completeUnit(Number(e.replace("em", "")), "em")))),
13
12
  t;
14
13
  }
15
14
 
package/lib/utils.js CHANGED
@@ -97,6 +97,12 @@ var null2default = function(e) {
97
97
  return e.forEach((function(e) {
98
98
  e in t && n++;
99
99
  })), e.length === n;
100
+ }, isOwnKeyInObject = function(e, t) {
101
+ isString(e) && (e = [ e ]);
102
+ var n = 0;
103
+ return e.forEach((function(e) {
104
+ e in t && hasOwnProperty.call(t, e) && n++;
105
+ })), e.length === n;
100
106
  }, simpleEqual = function(e, t) {
101
107
  if (e === t) return !0;
102
108
  if ("object" !== (0, _typeof2.default)(e) || null === e || "object" !== (0, _typeof2.default)(t) || null === t) return !1;
@@ -118,6 +124,18 @@ var null2default = function(e) {
118
124
  return t > 0 ? e.substring(t + 1) : "";
119
125
  }
120
126
  return "";
127
+ }, fileSizeToByte = function(e) {
128
+ var t = {
129
+ t: 1099511627776,
130
+ g: 1073741824,
131
+ m: 1048576,
132
+ k: 1024
133
+ };
134
+ if (!e) return 0;
135
+ if (!isString(e)) return e;
136
+ e = e.toLocaleLowerCase().replace(/\s*/g, "");
137
+ var n = (e = /^([0-9\.]+)([tgmk]?)b?$/i.exec(e))[2];
138
+ return e = +e[1], t.hasOwnProperty(n) && (e *= t[n]), e;
121
139
  }, some = function(e, t) {
122
140
  if (null == e) throw new TypeError;
123
141
  var n = Object(e), r = n.length >>> 0;
@@ -223,10 +241,12 @@ module.exports = {
223
241
  isJson: isJson,
224
242
  stringIsJson: stringIsJson,
225
243
  isKeyInObject: isKeyInObject,
244
+ isOwnKeyInObject: isOwnKeyInObject,
226
245
  simpleEqual: simpleEqual,
227
246
  isImageSrc: isImageSrc,
228
247
  encodeNumber: encodeNumber,
229
248
  getFileExtension: getFileExtension,
249
+ fileSizeToByte: fileSizeToByte,
230
250
  some: some,
231
251
  every: every,
232
252
  reduce: reduce,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amos-tool",
3
- "version": "1.4.9",
3
+ "version": "1.4.12",
4
4
  "description": "amos ui tool",
5
5
  "main": "index.js",
6
6
  "directories": {