@daysnap/utils 0.0.1

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 (199) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/dist/base64ToBlob.d.ts +4 -0
  4. package/dist/blobToBase64.d.ts +4 -0
  5. package/dist/compareVersion.d.ts +7 -0
  6. package/dist/compressImage.d.ts +4 -0
  7. package/dist/createHexColorByHash.d.ts +4 -0
  8. package/dist/downloadFile.d.ts +6 -0
  9. package/dist/filterBankCardNo.d.ts +4 -0
  10. package/dist/filterEmoji.d.ts +4 -0
  11. package/dist/filterIdCard.d.ts +4 -0
  12. package/dist/filterName.d.ts +4 -0
  13. package/dist/filterPhone.d.ts +6 -0
  14. package/dist/formatAmount.d.ts +4 -0
  15. package/dist/formatDate.d.ts +4 -0
  16. package/dist/getBlobByUrl.d.ts +4 -0
  17. package/dist/getImageInfo.d.ts +4 -0
  18. package/dist/getVideoInfo.d.ts +4 -0
  19. package/dist/index.d.ts +38 -0
  20. package/dist/index.js +604 -0
  21. package/dist/isAndroid.d.ts +4 -0
  22. package/dist/isEmail.d.ts +4 -0
  23. package/dist/isEmpty.d.ts +4 -0
  24. package/dist/isFunction.d.ts +4 -0
  25. package/dist/isIOS.d.ts +4 -0
  26. package/dist/isIdCard.d.ts +4 -0
  27. package/dist/isMobile.d.ts +4 -0
  28. package/dist/isNull.d.ts +4 -0
  29. package/dist/isObject.d.ts +4 -0
  30. package/dist/isPhone.d.ts +4 -0
  31. package/dist/isPromise.d.ts +4 -0
  32. package/dist/isRegExp.d.ts +4 -0
  33. package/dist/isString.d.ts +4 -0
  34. package/dist/isUndefined.d.ts +4 -0
  35. package/dist/omit.d.ts +4 -0
  36. package/dist/parseError.d.ts +4 -0
  37. package/dist/parsePath.d.ts +4 -0
  38. package/dist/pick.d.ts +4 -0
  39. package/dist/replaceCrlf.d.ts +4 -0
  40. package/dist/reserve.d.ts +7 -0
  41. package/dist/storage/factory.d.ts +13 -0
  42. package/dist/storage/index.d.ts +26 -0
  43. package/es/base64ToBlob.d.ts +4 -0
  44. package/es/base64ToBlob.js +55 -0
  45. package/es/blobToBase64.d.ts +4 -0
  46. package/es/blobToBase64.js +20 -0
  47. package/es/compareVersion.d.ts +7 -0
  48. package/es/compareVersion.js +58 -0
  49. package/es/compressImage.d.ts +4 -0
  50. package/es/compressImage.js +20 -0
  51. package/es/createHexColorByHash.d.ts +4 -0
  52. package/es/createHexColorByHash.js +72 -0
  53. package/es/downloadFile.d.ts +6 -0
  54. package/es/downloadFile.js +20 -0
  55. package/es/filterBankCardNo.d.ts +4 -0
  56. package/es/filterBankCardNo.js +11 -0
  57. package/es/filterEmoji.d.ts +4 -0
  58. package/es/filterEmoji.js +17 -0
  59. package/es/filterIdCard.d.ts +4 -0
  60. package/es/filterIdCard.js +8 -0
  61. package/es/filterName.d.ts +4 -0
  62. package/es/filterName.js +23 -0
  63. package/es/filterPhone.d.ts +6 -0
  64. package/es/filterPhone.js +11 -0
  65. package/es/formatAmount.d.ts +4 -0
  66. package/es/formatAmount.js +31 -0
  67. package/es/formatDate.d.ts +4 -0
  68. package/es/formatDate.js +44 -0
  69. package/es/getBlobByUrl.d.ts +4 -0
  70. package/es/getBlobByUrl.js +27 -0
  71. package/es/getImageInfo.d.ts +4 -0
  72. package/es/getImageInfo.js +18 -0
  73. package/es/getVideoInfo.d.ts +4 -0
  74. package/es/getVideoInfo.js +20 -0
  75. package/es/index.d.ts +38 -0
  76. package/es/index.js +39 -0
  77. package/es/isAndroid.d.ts +4 -0
  78. package/es/isAndroid.js +8 -0
  79. package/es/isEmail.d.ts +4 -0
  80. package/es/isEmail.js +8 -0
  81. package/es/isEmpty.d.ts +4 -0
  82. package/es/isEmpty.js +9 -0
  83. package/es/isFunction.d.ts +4 -0
  84. package/es/isFunction.js +6 -0
  85. package/es/isIOS.d.ts +4 -0
  86. package/es/isIOS.js +8 -0
  87. package/es/isIdCard.d.ts +4 -0
  88. package/es/isIdCard.js +8 -0
  89. package/es/isMobile.d.ts +4 -0
  90. package/es/isMobile.js +13 -0
  91. package/es/isNull.d.ts +4 -0
  92. package/es/isNull.js +6 -0
  93. package/es/isObject.d.ts +4 -0
  94. package/es/isObject.js +8 -0
  95. package/es/isPhone.d.ts +4 -0
  96. package/es/isPhone.js +8 -0
  97. package/es/isPromise.d.ts +4 -0
  98. package/es/isPromise.js +9 -0
  99. package/es/isRegExp.d.ts +4 -0
  100. package/es/isRegExp.js +10 -0
  101. package/es/isString.d.ts +4 -0
  102. package/es/isString.js +6 -0
  103. package/es/isUndefined.d.ts +4 -0
  104. package/es/isUndefined.js +6 -0
  105. package/es/omit.d.ts +4 -0
  106. package/es/omit.js +17 -0
  107. package/es/parseError.d.ts +4 -0
  108. package/es/parseError.js +28 -0
  109. package/es/parsePath.d.ts +4 -0
  110. package/es/parsePath.js +15 -0
  111. package/es/pick.d.ts +4 -0
  112. package/es/pick.js +14 -0
  113. package/es/replaceCrlf.d.ts +4 -0
  114. package/es/replaceCrlf.js +9 -0
  115. package/es/reserve.d.ts +7 -0
  116. package/es/reserve.js +11 -0
  117. package/es/storage/factory.d.ts +13 -0
  118. package/es/storage/factory.js +65 -0
  119. package/es/storage/index.d.ts +26 -0
  120. package/es/storage/index.js +3 -0
  121. package/lib/base64ToBlob.d.ts +4 -0
  122. package/lib/base64ToBlob.js +93 -0
  123. package/lib/blobToBase64.d.ts +4 -0
  124. package/lib/blobToBase64.js +28 -0
  125. package/lib/compareVersion.d.ts +7 -0
  126. package/lib/compareVersion.js +68 -0
  127. package/lib/compressImage.d.ts +4 -0
  128. package/lib/compressImage.js +27 -0
  129. package/lib/createHexColorByHash.d.ts +4 -0
  130. package/lib/createHexColorByHash.js +84 -0
  131. package/lib/downloadFile.d.ts +6 -0
  132. package/lib/downloadFile.js +32 -0
  133. package/lib/filterBankCardNo.d.ts +4 -0
  134. package/lib/filterBankCardNo.js +21 -0
  135. package/lib/filterEmoji.d.ts +4 -0
  136. package/lib/filterEmoji.js +28 -0
  137. package/lib/filterIdCard.d.ts +4 -0
  138. package/lib/filterIdCard.js +15 -0
  139. package/lib/filterName.d.ts +4 -0
  140. package/lib/filterName.js +31 -0
  141. package/lib/filterPhone.d.ts +6 -0
  142. package/lib/filterPhone.js +18 -0
  143. package/lib/formatAmount.d.ts +4 -0
  144. package/lib/formatAmount.js +42 -0
  145. package/lib/formatDate.d.ts +4 -0
  146. package/lib/formatDate.js +55 -0
  147. package/lib/getBlobByUrl.d.ts +4 -0
  148. package/lib/getBlobByUrl.js +36 -0
  149. package/lib/getImageInfo.d.ts +4 -0
  150. package/lib/getImageInfo.js +26 -0
  151. package/lib/getVideoInfo.d.ts +4 -0
  152. package/lib/getVideoInfo.js +28 -0
  153. package/lib/index.d.ts +38 -0
  154. package/lib/index.js +537 -0
  155. package/lib/isAndroid.d.ts +4 -0
  156. package/lib/isAndroid.js +15 -0
  157. package/lib/isEmail.d.ts +4 -0
  158. package/lib/isEmail.js +15 -0
  159. package/lib/isEmpty.d.ts +4 -0
  160. package/lib/isEmpty.js +17 -0
  161. package/lib/isFunction.d.ts +4 -0
  162. package/lib/isFunction.js +13 -0
  163. package/lib/isIOS.d.ts +4 -0
  164. package/lib/isIOS.js +15 -0
  165. package/lib/isIdCard.d.ts +4 -0
  166. package/lib/isIdCard.js +15 -0
  167. package/lib/isMobile.d.ts +4 -0
  168. package/lib/isMobile.js +20 -0
  169. package/lib/isNull.d.ts +4 -0
  170. package/lib/isNull.js +13 -0
  171. package/lib/isObject.d.ts +4 -0
  172. package/lib/isObject.js +15 -0
  173. package/lib/isPhone.d.ts +4 -0
  174. package/lib/isPhone.js +15 -0
  175. package/lib/isPromise.d.ts +4 -0
  176. package/lib/isPromise.js +17 -0
  177. package/lib/isRegExp.d.ts +4 -0
  178. package/lib/isRegExp.js +19 -0
  179. package/lib/isString.d.ts +4 -0
  180. package/lib/isString.js +13 -0
  181. package/lib/isUndefined.d.ts +4 -0
  182. package/lib/isUndefined.js +13 -0
  183. package/lib/omit.d.ts +4 -0
  184. package/lib/omit.js +26 -0
  185. package/lib/parseError.d.ts +4 -0
  186. package/lib/parseError.js +37 -0
  187. package/lib/parsePath.d.ts +4 -0
  188. package/lib/parsePath.js +23 -0
  189. package/lib/pick.d.ts +4 -0
  190. package/lib/pick.js +22 -0
  191. package/lib/replaceCrlf.d.ts +4 -0
  192. package/lib/replaceCrlf.js +17 -0
  193. package/lib/reserve.d.ts +7 -0
  194. package/lib/reserve.js +18 -0
  195. package/lib/storage/factory.d.ts +13 -0
  196. package/lib/storage/factory.js +75 -0
  197. package/lib/storage/index.d.ts +26 -0
  198. package/lib/storage/index.js +13 -0
  199. package/package.json +94 -0
@@ -0,0 +1,4 @@
1
+ /**
2
+ * blob 转 base64
3
+ */
4
+ export declare function blobToBase64(blob: Blob): Promise<string | ArrayBuffer>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.blobToBase64 = blobToBase64;
7
+
8
+ require("core-js/modules/es.object.to-string.js");
9
+
10
+ require("core-js/modules/es.promise.js");
11
+
12
+ /**
13
+ * blob 转 base64
14
+ */
15
+ function blobToBase64(blob) {
16
+ return new Promise(function (resolve, reject) {
17
+ var fileReader = new FileReader();
18
+
19
+ fileReader.onload = function (res) {
20
+ var _res$target$result, _res$target;
21
+
22
+ resolve((_res$target$result = (_res$target = res.target) === null || _res$target === void 0 ? void 0 : _res$target.result) !== null && _res$target$result !== void 0 ? _res$target$result : '');
23
+ };
24
+
25
+ fileReader.onerror = reject;
26
+ fileReader.readAsDataURL(blob);
27
+ });
28
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 比对版本
3
+ * -1 => V < v
4
+ * 0 => V === v
5
+ * 1 => V > v
6
+ */
7
+ export declare function compareVersion(V: string, v: string): number;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.compareVersion = compareVersion;
9
+
10
+ require("core-js/modules/es.array.map.js");
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ /**
15
+ * 比对版本
16
+ * -1 => V < v
17
+ * 0 => V === v
18
+ * 1 => V > v
19
+ */
20
+ function compareVersion(V, v) {
21
+ var _V$split$map = V.split('.').map(function (i) {
22
+ return +i;
23
+ }),
24
+ _V$split$map2 = (0, _slicedToArray2.default)(_V$split$map, 3),
25
+ _V$split$map2$ = _V$split$map2[0],
26
+ H = _V$split$map2$ === void 0 ? 0 : _V$split$map2$,
27
+ _V$split$map2$2 = _V$split$map2[1],
28
+ T = _V$split$map2$2 === void 0 ? 0 : _V$split$map2$2,
29
+ _V$split$map2$3 = _V$split$map2[2],
30
+ S = _V$split$map2$3 === void 0 ? 0 : _V$split$map2$3; // 新
31
+
32
+
33
+ var _v$split$map = v.split('.').map(function (i) {
34
+ return +i;
35
+ }),
36
+ _v$split$map2 = (0, _slicedToArray2.default)(_v$split$map, 3),
37
+ _v$split$map2$ = _v$split$map2[0],
38
+ h = _v$split$map2$ === void 0 ? 0 : _v$split$map2$,
39
+ _v$split$map2$2 = _v$split$map2[1],
40
+ t = _v$split$map2$2 === void 0 ? 0 : _v$split$map2$2,
41
+ _v$split$map2$3 = _v$split$map2[2],
42
+ s = _v$split$map2$3 === void 0 ? 0 : _v$split$map2$3; // 本
43
+
44
+
45
+ var result = 0;
46
+
47
+ if (H > h) {
48
+ result = 1;
49
+ } else if (H === h) {
50
+ if (T > t) {
51
+ result = 1;
52
+ } else if (T === t) {
53
+ if (S > s) {
54
+ result = 1;
55
+ } else if (S === s) {
56
+ result = 0;
57
+ } else {
58
+ result = -1;
59
+ }
60
+ } else {
61
+ result = -1;
62
+ }
63
+ } else {
64
+ result = -1;
65
+ }
66
+
67
+ return result;
68
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 压缩图片
3
+ */
4
+ export declare function compressImage(image: CanvasImageSource): HTMLCanvasElement;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.compressImage = compressImage;
7
+
8
+ var _pick2 = require("./pick");
9
+
10
+ /**
11
+ * 压缩图片
12
+ */
13
+ function compressImage(image) {
14
+ var _pick = (0, _pick2.pick)(image, ['width', 'height']),
15
+ width = _pick.width,
16
+ height = _pick.height;
17
+
18
+ var canvas = document.createElement('canvas'); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19
+
20
+ var ctx = canvas.getContext('2d');
21
+ canvas.width = width;
22
+ canvas.height = height;
23
+ ctx.fillStyle = '#fff';
24
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
25
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
26
+ return canvas;
27
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 根据字符串hash值生成颜色值
3
+ */
4
+ export declare const colorGenByHash: (str: string) => string;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.colorGenByHash = void 0;
7
+
8
+ require("core-js/modules/es.object.to-string.js");
9
+
10
+ require("core-js/modules/es.regexp.to-string.js");
11
+
12
+ require("core-js/modules/es.array.map.js");
13
+
14
+ require("core-js/modules/web.dom-collections.for-each.js");
15
+
16
+ /**
17
+ * 根据字符串hash值生成颜色值
18
+ */
19
+ var colorGenByHash = function colorGenByHash(str) {
20
+ var lsL = [0.35, 0.5, 0.65];
21
+ var lsS = [0.35, 0.5, 0.65];
22
+ var seed = 131;
23
+ var seed2 = 137;
24
+ var hash = 0; // eslint-disable-next-line no-param-reassign
25
+
26
+ str += 'x';
27
+ var MAX_SAFE_INTEGER = parseInt((9007199254740991 / seed2).toString(), 10);
28
+
29
+ for (var i = 0; i < str.length; i++) {
30
+ if (hash > MAX_SAFE_INTEGER) {
31
+ hash = parseInt((hash / seed2).toString(), 10);
32
+ }
33
+
34
+ hash = hash * seed + str.charCodeAt(i);
35
+ }
36
+
37
+ var H;
38
+ H = hash % 359;
39
+ hash = parseInt((hash / 360).toString(), 10);
40
+ var S = lsS[hash % lsS.length];
41
+ hash = parseInt((hash / lsS.length).toString(), 10);
42
+ var L = lsL[hash % lsL.length];
43
+ H /= 360;
44
+ var q = L < 0.5 ? L * (1 + S) : L + S - L * S;
45
+ var p = 2 * L - q;
46
+ var RGBArray = [H + 1 / 3, H, H - 1 / 3].map(function (color) {
47
+ if (color < 0) {
48
+ // eslint-disable-next-line no-param-reassign
49
+ color++;
50
+ }
51
+
52
+ if (color > 1) {
53
+ // eslint-disable-next-line no-param-reassign
54
+ color--;
55
+ }
56
+
57
+ if (color < 1 / 6) {
58
+ // eslint-disable-next-line no-param-reassign
59
+ color = p + (q - p) * 6 * color;
60
+ } else if (color < 0.5) {
61
+ // eslint-disable-next-line no-param-reassign
62
+ color = q;
63
+ } else if (color < 2 / 3) {
64
+ // eslint-disable-next-line no-param-reassign
65
+ color = p + (q - p) * 6 * (2 / 3 - color);
66
+ } else {
67
+ // eslint-disable-next-line no-param-reassign
68
+ color = p;
69
+ }
70
+
71
+ return Math.round(color * 255);
72
+ });
73
+ var hex = '#';
74
+ RGBArray.forEach(function (value) {
75
+ if (value < 16) {
76
+ hex += 0;
77
+ }
78
+
79
+ hex += value.toString(16);
80
+ });
81
+ return hex;
82
+ };
83
+
84
+ exports.colorGenByHash = colorGenByHash;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 通过 a 标签下载文件
3
+ */
4
+ export declare function downloadFile(data: string | Blob | MediaSource, options?: {
5
+ fileName?: string;
6
+ }): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.downloadFile = downloadFile;
7
+
8
+ require("core-js/modules/es.array.iterator.js");
9
+
10
+ require("core-js/modules/es.object.to-string.js");
11
+
12
+ require("core-js/modules/es.string.iterator.js");
13
+
14
+ require("core-js/modules/web.dom-collections.iterator.js");
15
+
16
+ require("core-js/modules/web.url.js");
17
+
18
+ require("core-js/modules/web.url-search-params.js");
19
+
20
+ /**
21
+ * 通过 a 标签下载文件
22
+ */
23
+ function downloadFile(data, options) {
24
+ var a = document.createElement('a');
25
+ a.href = typeof data === 'string' ? data : URL.createObjectURL(data);
26
+
27
+ if (options !== null && options !== void 0 && options.fileName) {
28
+ a.download = options.fileName;
29
+ }
30
+
31
+ a.click();
32
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 过滤银行卡号
3
+ */
4
+ export declare function filterBankCardNo(val: string): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterBankCardNo = filterBankCardNo;
7
+
8
+ require("core-js/modules/es.regexp.exec.js");
9
+
10
+ require("core-js/modules/es.string.replace.js");
11
+
12
+ require("core-js/modules/es.array.concat.js");
13
+
14
+ require("core-js/modules/es.array.join.js");
15
+
16
+ /**
17
+ * 过滤银行卡号
18
+ */
19
+ function filterBankCardNo(val) {
20
+ return val ? "".concat(new Array(val.length - 3).join('*')).concat(val.substring(val.length - 4)).replace(/(.{4})/g, '$1 ') : '';
21
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 过滤emoji
3
+ */
4
+ export declare function filterEmoji(val: string): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterEmoji = filterEmoji;
7
+
8
+ require("core-js/modules/es.regexp.exec.js");
9
+
10
+ require("core-js/modules/es.string.replace.js");
11
+
12
+ require("core-js/modules/es.regexp.constructor.js");
13
+
14
+ require("core-js/modules/es.regexp.to-string.js");
15
+
16
+ require("core-js/modules/es.array.join.js");
17
+
18
+ /**
19
+ * 过滤emoji
20
+ */
21
+ function filterEmoji(val) {
22
+ if (!val) {
23
+ return '';
24
+ }
25
+
26
+ var ranges = ["\uD83C[\uDF00-\uDFFF]", "\uD83D[\uDC00-\uDE4F]", "\uD83D[\uDE80-\uDEFF]", "[\uD800-\uDBFF]", "[\uDC00-\uDFFF]", "[^ -~\xA0-\xBE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\x80-\x9F\u2000-\u201F\u2026\u2022\u20AC\r\n]"];
27
+ return val.replace(new RegExp(ranges.join('|'), 'g'), '');
28
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 身份证号码加 *
3
+ */
4
+ export declare function filterIdCard(val: string): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterIdCard = filterIdCard;
7
+
8
+ require("core-js/modules/es.array.concat.js");
9
+
10
+ /**
11
+ * 身份证号码加 *
12
+ */
13
+ function filterIdCard(val) {
14
+ return val ? "".concat(val.substring(0, 6), "********").concat(val.substring(14)) : '';
15
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 过滤姓名
3
+ */
4
+ export declare function filterName(val: string): string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterName = filterName;
7
+
8
+ require("core-js/modules/es.array.concat.js");
9
+
10
+ require("core-js/modules/es.array.join.js");
11
+
12
+ /**
13
+ * 过滤姓名
14
+ */
15
+ function filterName(val) {
16
+ if (!val) {
17
+ return '';
18
+ }
19
+
20
+ var len = val.length;
21
+
22
+ if (len === 1) {
23
+ return val;
24
+ }
25
+
26
+ if (len === 2) {
27
+ return "".concat(val.substring(0, 1), "*");
28
+ }
29
+
30
+ return "".concat(val.substring(0, 1)).concat(new Array(len - 1).join('*')).concat(val.substr(-1));
31
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 手机号加 *
3
+ * filterPhone('13177778888') => 131****8888
4
+ * filterPhone('13177778888', ' ') => 131 **** 8888
5
+ */
6
+ export declare function filterPhone(val: string, sep?: string): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterPhone = filterPhone;
7
+
8
+ require("core-js/modules/es.array.concat.js");
9
+
10
+ /**
11
+ * 手机号加 *
12
+ * filterPhone('13177778888') => 131****8888
13
+ * filterPhone('13177778888', ' ') => 131 **** 8888
14
+ */
15
+ function filterPhone(val) {
16
+ var sep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
17
+ return val ? "".concat(val.substring(0, 3)).concat(sep, "****").concat(sep).concat(val.substring(7)) : '';
18
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 格式化金额,默认元
3
+ */
4
+ export declare function formatAmount(s: string, radix?: number): string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatAmount = formatAmount;
7
+
8
+ require("core-js/modules/es.number.to-fixed.js");
9
+
10
+ require("core-js/modules/es.object.to-string.js");
11
+
12
+ require("core-js/modules/web.dom-collections.for-each.js");
13
+
14
+ require("core-js/modules/es.array.concat.js");
15
+
16
+ require("core-js/modules/es.array.join.js");
17
+
18
+ /**
19
+ * 格式化金额,默认元
20
+ */
21
+ function formatAmount(s) {
22
+ var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
23
+ var money = parseFloat(s);
24
+
25
+ if (money) {
26
+ // eslint-disable-next-line no-param-reassign
27
+ s = "".concat((money / radix).toFixed(2));
28
+ var l = s.split('.')[0].split('').reverse();
29
+ var r = s.split('.')[1];
30
+ var t = '';
31
+ l.forEach(function (_, key) {
32
+ t += l[key] + ((key + 1) % 3 === 0 && key + 1 !== l.length ? ',' : '');
33
+ });
34
+ return "".concat(t.split('').reverse().join(''), ".").concat(r);
35
+ }
36
+
37
+ if (+s === 0) {
38
+ return '0.00';
39
+ }
40
+
41
+ return '---';
42
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 格式化日期
3
+ */
4
+ export declare function formatDate(val: string | Date | number, fmt?: string): string;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatDate = formatDate;
7
+
8
+ require("core-js/modules/es.regexp.exec.js");
9
+
10
+ require("core-js/modules/es.string.replace.js");
11
+
12
+ require("core-js/modules/es.regexp.constructor.js");
13
+
14
+ require("core-js/modules/es.regexp.to-string.js");
15
+
16
+ var _isString = require("./isString");
17
+
18
+ /**
19
+ * 格式化日期
20
+ */
21
+ function formatDate(val) {
22
+ var fmt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd hh:mm:ss';
23
+ var v = val;
24
+
25
+ if ((0, _isString.isString)(v)) {
26
+ // fix iOS new Date() 不支持 2020-01-01 格式,需转换为 2020/01/01
27
+ v = v.replace(/-/g, '/');
28
+ }
29
+
30
+ var date = new Date(v);
31
+ var o = {
32
+ 'M+': date.getMonth() + 1,
33
+ 'd+': date.getDate(),
34
+ 'h+': date.getHours(),
35
+ 'm+': date.getMinutes(),
36
+ 's+': date.getSeconds(),
37
+ 'q+': Math.floor((date.getMonth() + 3) / 3),
38
+ S: date.getMilliseconds()
39
+ };
40
+
41
+ if (/(y+)/.test(fmt)) {
42
+ // eslint-disable-next-line no-param-reassign
43
+ fmt = fmt.replace(RegExp.$1, "".concat(date.getFullYear()).substr(4 - RegExp.$1.length));
44
+ } // eslint-disable-next-line no-restricted-syntax
45
+
46
+
47
+ for (var k in o) {
48
+ if (new RegExp("(".concat(k, ")")).test(fmt)) {
49
+ // eslint-disable-next-line no-param-reassign
50
+ fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : "00".concat(o[k]).substr("".concat(o[k]).length));
51
+ }
52
+ }
53
+
54
+ return fmt;
55
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 根据在线 url 返回 blob
3
+ */
4
+ export declare function getBlobByUrl(url: string): Promise<Blob>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBlobByUrl = getBlobByUrl;
7
+
8
+ require("core-js/modules/es.object.to-string.js");
9
+
10
+ require("core-js/modules/es.promise.js");
11
+
12
+ require("core-js/modules/es.array.concat.js");
13
+
14
+ /**
15
+ * 根据在线 url 返回 blob
16
+ */
17
+ function getBlobByUrl(url) {
18
+ return new Promise(function (resolve, reject) {
19
+ var xhr = new XMLHttpRequest();
20
+ xhr.open('GET', url, true);
21
+ xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
22
+ xhr.responseType = 'blob';
23
+
24
+ xhr.onload = function () {
25
+ var status = xhr.status,
26
+ response = xhr.response,
27
+ statusText = xhr.statusText;
28
+
29
+ if (status >= 200 && status < 300) {
30
+ resolve(response);
31
+ } else {
32
+ reject(new Error("".concat(statusText, "[").concat(status, "]")));
33
+ }
34
+ };
35
+ });
36
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 获取图片信息
3
+ */
4
+ export declare function getImageInfo(src: string): Promise<HTMLImageElement>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getImageInfo = getImageInfo;
7
+
8
+ require("core-js/modules/es.object.to-string.js");
9
+
10
+ require("core-js/modules/es.promise.js");
11
+
12
+ /**
13
+ * 获取图片信息
14
+ */
15
+ function getImageInfo(src) {
16
+ return new Promise(function (resolve, reject) {
17
+ var image = new Image();
18
+
19
+ image.onload = function () {
20
+ resolve(image);
21
+ };
22
+
23
+ image.onerror = reject;
24
+ image.src = src;
25
+ });
26
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 获取 video 信息
3
+ */
4
+ export declare function getVideoInfo(src: string): Promise<HTMLVideoElement>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getVideoInfo = getVideoInfo;
7
+
8
+ require("core-js/modules/es.object.to-string.js");
9
+
10
+ require("core-js/modules/es.promise.js");
11
+
12
+ /**
13
+ * 获取 video 信息
14
+ */
15
+ function getVideoInfo(src) {
16
+ return new Promise(function (resolve, reject) {
17
+ var video = document.createElement('video');
18
+ video.preload = 'metadata';
19
+ video.muted = true;
20
+ video.onerror = reject;
21
+
22
+ video.onloadedmetadata = function () {
23
+ resolve(video);
24
+ };
25
+
26
+ video.src = src;
27
+ });
28
+ }