@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
package/es/index.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ export declare const version = "0.0.3";
2
+ export * from './base64ToBlob';
3
+ export * from './blobToBase64';
4
+ export * from './compareVersion';
5
+ export * from './compressImage';
6
+ export * from './createHexColorByHash';
7
+ export * from './downloadFile';
8
+ export * from './filterBankCardNo';
9
+ export * from './filterEmoji';
10
+ export * from './filterIdCard';
11
+ export * from './filterName';
12
+ export * from './filterPhone';
13
+ export * from './formatAmount';
14
+ export * from './formatDate';
15
+ export * from './getBlobByUrl';
16
+ export * from './getImageInfo';
17
+ export * from './getVideoInfo';
18
+ export * from './isAndroid';
19
+ export * from './isEmail';
20
+ export * from './isEmpty';
21
+ export * from './isFunction';
22
+ export * from './isIOS';
23
+ export * from './isIdCard';
24
+ export * from './isMobile';
25
+ export * from './isNull';
26
+ export * from './isObject';
27
+ export * from './isPhone';
28
+ export * from './isPromise';
29
+ export * from './isRegExp';
30
+ export * from './isString';
31
+ export * from './isUndefined';
32
+ export * from './omit';
33
+ export * from './parseError';
34
+ export * from './parsePath';
35
+ export * from './pick';
36
+ export * from './replaceCrlf';
37
+ export * from './reserve';
38
+ export * from './storage';
package/es/index.js ADDED
@@ -0,0 +1,39 @@
1
+ /* 本文件自动生成 './scripts/entry.js' */
2
+ export var version = '0.0.3';
3
+ export * from './base64ToBlob';
4
+ export * from './blobToBase64';
5
+ export * from './compareVersion';
6
+ export * from './compressImage';
7
+ export * from './createHexColorByHash';
8
+ export * from './downloadFile';
9
+ export * from './filterBankCardNo';
10
+ export * from './filterEmoji';
11
+ export * from './filterIdCard';
12
+ export * from './filterName';
13
+ export * from './filterPhone';
14
+ export * from './formatAmount';
15
+ export * from './formatDate';
16
+ export * from './getBlobByUrl';
17
+ export * from './getImageInfo';
18
+ export * from './getVideoInfo';
19
+ export * from './isAndroid';
20
+ export * from './isEmail';
21
+ export * from './isEmpty';
22
+ export * from './isFunction';
23
+ export * from './isIOS';
24
+ export * from './isIdCard';
25
+ export * from './isMobile';
26
+ export * from './isNull';
27
+ export * from './isObject';
28
+ export * from './isPhone';
29
+ export * from './isPromise';
30
+ export * from './isRegExp';
31
+ export * from './isString';
32
+ export * from './isUndefined';
33
+ export * from './omit';
34
+ export * from './parseError';
35
+ export * from './parsePath';
36
+ export * from './pick';
37
+ export * from './replaceCrlf';
38
+ export * from './reserve';
39
+ export * from './storage';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是安卓
3
+ */
4
+ export declare function isAndroid(): boolean;
@@ -0,0 +1,8 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+
3
+ /**
4
+ * 校验是否是安卓
5
+ */
6
+ export function isAndroid() {
7
+ return /android/.test(navigator.userAgent.toLowerCase());
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是邮箱
3
+ */
4
+ export declare function isEmail(val: string): boolean;
package/es/isEmail.js ADDED
@@ -0,0 +1,8 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+
3
+ /**
4
+ * 校验是否是邮箱
5
+ */
6
+ export function isEmail(val) {
7
+ return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(val);
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否为空 ''、undefined、null
3
+ */
4
+ export declare function isEmpty(val: unknown): boolean;
package/es/isEmpty.js ADDED
@@ -0,0 +1,9 @@
1
+ import { isNull } from './isNull';
2
+ import { isUndefined } from './isUndefined';
3
+ /**
4
+ * 校验是否为空 ''、undefined、null
5
+ */
6
+
7
+ export function isEmpty(val) {
8
+ return val === '' || isNull(val) || isUndefined(val);
9
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是函数
3
+ */
4
+ export declare function isFunction(val: unknown): val is (...args: any[]) => any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 校验是否是函数
3
+ */
4
+ export function isFunction(val) {
5
+ return typeof val === 'function';
6
+ }
package/es/isIOS.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是ios
3
+ */
4
+ export declare function isIOS(): boolean;
package/es/isIOS.js ADDED
@@ -0,0 +1,8 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+
3
+ /**
4
+ * 校验是否是ios
5
+ */
6
+ export function isIOS() {
7
+ return /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是身份证
3
+ */
4
+ export declare function isIdCard(val: string): boolean;
package/es/isIdCard.js ADDED
@@ -0,0 +1,8 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+
3
+ /**
4
+ * 校验是否是身份证
5
+ */
6
+ export function isIdCard(val) {
7
+ return /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test(val);
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验设备是否是手机
3
+ */
4
+ export declare function isMobile(): boolean;
package/es/isMobile.js ADDED
@@ -0,0 +1,13 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+
3
+ /**
4
+ * 校验设备是否是手机
5
+ */
6
+ export function isMobile() {
7
+ if (typeof navigator === 'undefined' || typeof window === 'undefined') {
8
+ return false;
9
+ }
10
+
11
+ var agent = navigator.userAgent || navigator.vendor || window.opera;
12
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substr(0, 4));
13
+ }
package/es/isNull.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是 null
3
+ */
4
+ export declare function isNull(val: unknown): val is null;
package/es/isNull.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 校验是否是 null
3
+ */
4
+ export function isNull(val) {
5
+ return val === null;
6
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是对象
3
+ */
4
+ export declare function isObject(val: unknown): val is Record<string, any>;
package/es/isObject.js ADDED
@@ -0,0 +1,8 @@
1
+ import "core-js/modules/es.object.to-string.js";
2
+
3
+ /**
4
+ * 校验是否是对象
5
+ */
6
+ export function isObject(val) {
7
+ return Object.prototype.toString.call(val) === '[object Object]';
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是手机号码
3
+ */
4
+ export declare function isPhone(val: string): boolean;
package/es/isPhone.js ADDED
@@ -0,0 +1,8 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+
3
+ /**
4
+ * 校验是否是手机号码
5
+ */
6
+ export function isPhone(val) {
7
+ return /^1\d{10}$/.test(val);
8
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是 promise
3
+ */
4
+ export declare function isPromise<T = any>(val: unknown): val is Promise<T>;
@@ -0,0 +1,9 @@
1
+ import "core-js/modules/es.object.to-string.js";
2
+ import "core-js/modules/es.promise.js";
3
+
4
+ /**
5
+ * 校验是否是 promise
6
+ */
7
+ export function isPromise(val) {
8
+ return val instanceof Promise || !!val.then || !!val.catch;
9
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是正则表达式
3
+ */
4
+ export declare function isRegExp(val: unknown): val is RegExp;
package/es/isRegExp.js ADDED
@@ -0,0 +1,10 @@
1
+ import "core-js/modules/es.regexp.constructor.js";
2
+ import "core-js/modules/es.regexp.exec.js";
3
+ import "core-js/modules/es.regexp.to-string.js";
4
+
5
+ /**
6
+ * 校验是否是正则表达式
7
+ */
8
+ export function isRegExp(val) {
9
+ return val instanceof RegExp;
10
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是字符串
3
+ */
4
+ export declare function isString(val: unknown): val is string;
package/es/isString.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 校验是否是字符串
3
+ */
4
+ export function isString(val) {
5
+ return typeof val === 'string';
6
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 校验是否是 undefined
3
+ */
4
+ export declare function isUndefined(val: unknown): val is undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 校验是否是 undefined
3
+ */
4
+ export function isUndefined(val) {
5
+ return typeof val === 'undefined';
6
+ }
package/es/omit.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 排除对象里的某些属性,返回剩下的对象,浅拷贝
3
+ */
4
+ export declare function omit<T extends object, K extends keyof T>(obj: T, fields?: K[]): Omit<T, K>;
package/es/omit.js ADDED
@@ -0,0 +1,17 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import "core-js/modules/es.object.to-string.js";
3
+ import "core-js/modules/web.dom-collections.for-each.js";
4
+
5
+ /**
6
+ * 排除对象里的某些属性,返回剩下的对象,浅拷贝
7
+ */
8
+ export function omit(obj) {
9
+ var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
10
+
11
+ var clone = _objectSpread({}, obj);
12
+
13
+ fields.forEach(function (key) {
14
+ delete clone[key];
15
+ });
16
+ return clone;
17
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 解析格式化 error 获取对应的 message
3
+ */
4
+ export declare function parseError(val: any, keys?: string[]): string;
@@ -0,0 +1,28 @@
1
+ import { isEmpty } from './isEmpty';
2
+ import { isObject } from './isObject';
3
+ import { isUndefined } from './isUndefined';
4
+ /**
5
+ * 解析格式化 error 获取对应的 message
6
+ */
7
+
8
+ export function parseError(val) {
9
+ var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['message', 'msg', 'errorMsg'];
10
+
11
+ if (isEmpty(val)) {
12
+ // null or '' or undefined
13
+ return '';
14
+ }
15
+
16
+ if (isObject(val)) {
17
+ for (var i = 0, len = keys.length; i < len; i++) {
18
+ var key = keys[i];
19
+ var v = val[key];
20
+
21
+ if (!isUndefined(v)) {
22
+ return v;
23
+ }
24
+ }
25
+ }
26
+
27
+ return JSON.stringify(val);
28
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 根据路径解析值
3
+ */
4
+ export declare function parsePath(obj: Record<string, any>, path: string): Record<string, any>;
@@ -0,0 +1,15 @@
1
+ import "core-js/modules/es.object.to-string.js";
2
+ import "core-js/modules/web.dom-collections.for-each.js";
3
+
4
+ /**
5
+ * 根据路径解析值
6
+ */
7
+ export function parsePath(obj, path) {
8
+ path.split('.').forEach(function (key) {
9
+ var _obj$key;
10
+
11
+ // eslint-disable-next-line no-param-reassign
12
+ obj = (_obj$key = obj[key]) !== null && _obj$key !== void 0 ? _obj$key : '';
13
+ });
14
+ return obj;
15
+ }
package/es/pick.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 挑选对象里的某些属性,新对象返回
3
+ */
4
+ export declare function pick<T extends object, K extends keyof T>(obj: T, fields?: K[]): Pick<T, K>;
package/es/pick.js ADDED
@@ -0,0 +1,14 @@
1
+ import "core-js/modules/es.object.to-string.js";
2
+ import "core-js/modules/web.dom-collections.for-each.js";
3
+
4
+ /**
5
+ * 挑选对象里的某些属性,新对象返回
6
+ */
7
+ export function pick(obj) {
8
+ var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
9
+ var clone = {};
10
+ fields.forEach(function (key) {
11
+ clone[key] = obj[key];
12
+ });
13
+ return clone;
14
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 替换字符串里面的回车换行
3
+ */
4
+ export declare function replaceCrlf(val: string, replaceVal: string): string;
@@ -0,0 +1,9 @@
1
+ import "core-js/modules/es.regexp.exec.js";
2
+ import "core-js/modules/es.string.replace.js";
3
+
4
+ /**
5
+ * 替换字符串里面的回车换行
6
+ */
7
+ export function replaceCrlf(val, replaceVal) {
8
+ return val ? val.replace(/\\r|\\n/gi, replaceVal) : '';
9
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 值为 ''、undefined、null 则取默认值
3
+ * 解决:
4
+ * 0 || '--' => '--'
5
+ * reserve(0, '--') => 0
6
+ */
7
+ export declare function reserve(val: any, defaultVal?: any): any;
package/es/reserve.js ADDED
@@ -0,0 +1,11 @@
1
+ import { isEmpty } from './isEmpty';
2
+ /**
3
+ * 值为 ''、undefined、null 则取默认值
4
+ * 解决:
5
+ * 0 || '--' => '--'
6
+ * reserve(0, '--') => 0
7
+ */
8
+
9
+ export function reserve(val, defaultVal) {
10
+ return isEmpty(val) ? defaultVal : val;
11
+ }
@@ -0,0 +1,13 @@
1
+ export declare function factory(type: 'sessionStorage' | 'localStorage'): {
2
+ setItem: <T>(key: string, val: T) => T;
3
+ getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
4
+ removeItem: (key: string) => void;
5
+ updateItem: <T_2>(key: string, val: Partial<T_2>) => T_2;
6
+ clear: () => void;
7
+ generate: <T_3>(key: string) => {
8
+ setItem: (val: T_3) => T_3;
9
+ getItem: (defaultVal?: Partial<T_3>) => any;
10
+ removeItem: () => void;
11
+ updateItem: (val: Partial<T_3>) => T_3;
12
+ };
13
+ };
@@ -0,0 +1,65 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ export function factory(type) {
3
+ var fn = window[type]; // 设置
4
+
5
+ var _setItem = function setItem(key, val) {
6
+ fn.setItem(key, JSON.stringify(val));
7
+ return val;
8
+ }; // 获取
9
+
10
+
11
+ var _getItem = function getItem(key) {
12
+ var defaultVal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
13
+ var val = fn.getItem(key); // 如果为 null 取默认值
14
+
15
+ if (val === null) {
16
+ return defaultVal;
17
+ }
18
+
19
+ return JSON.parse(val);
20
+ }; // 删除
21
+
22
+
23
+ var _removeItem = function removeItem(key) {
24
+ fn.removeItem(key);
25
+ }; // 更新
26
+
27
+
28
+ var _updateItem = function updateItem(key, val) {
29
+ var prev = _getItem(key);
30
+
31
+ return _setItem(key, _objectSpread(_objectSpread({}, prev), val));
32
+ }; // 清除
33
+
34
+
35
+ var clear = function clear() {
36
+ fn.clear();
37
+ }; // 生成
38
+
39
+
40
+ var generate = function generate(key) {
41
+ return {
42
+ setItem: function setItem(val) {
43
+ return _setItem(key, val);
44
+ },
45
+ getItem: function getItem(defaultVal) {
46
+ return _getItem(key, defaultVal);
47
+ },
48
+ removeItem: function removeItem() {
49
+ return _removeItem(key);
50
+ },
51
+ updateItem: function updateItem(val) {
52
+ return _updateItem(key, val);
53
+ }
54
+ };
55
+ };
56
+
57
+ return {
58
+ setItem: _setItem,
59
+ getItem: _getItem,
60
+ removeItem: _removeItem,
61
+ updateItem: _updateItem,
62
+ clear: clear,
63
+ generate: generate
64
+ };
65
+ }
@@ -0,0 +1,26 @@
1
+ export declare const cache: {
2
+ setItem: <T>(key: string, val: T) => T;
3
+ getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
4
+ removeItem: (key: string) => void;
5
+ updateItem: <T_2>(key: string, val: Partial<T_2>) => T_2;
6
+ clear: () => void;
7
+ generate: <T_3>(key: string) => {
8
+ setItem: (val: T_3) => T_3;
9
+ getItem: (defaultVal?: Partial<T_3>) => any;
10
+ removeItem: () => void;
11
+ updateItem: (val: Partial<T_3>) => T_3;
12
+ };
13
+ };
14
+ export declare const local: {
15
+ setItem: <T>(key: string, val: T) => T;
16
+ getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
17
+ removeItem: (key: string) => void;
18
+ updateItem: <T_2>(key: string, val: Partial<T_2>) => T_2;
19
+ clear: () => void;
20
+ generate: <T_3>(key: string) => {
21
+ setItem: (val: T_3) => T_3;
22
+ getItem: (defaultVal?: Partial<T_3>) => any;
23
+ removeItem: () => void;
24
+ updateItem: (val: Partial<T_3>) => T_3;
25
+ };
26
+ };
@@ -0,0 +1,3 @@
1
+ import { factory } from './factory';
2
+ export var cache = factory('sessionStorage');
3
+ export var local = factory('localStorage');
@@ -0,0 +1,4 @@
1
+ /**
2
+ * base64 转 blob
3
+ */
4
+ export declare function base64ToBlob(base64: string, contentType?: string): Blob;
@@ -0,0 +1,93 @@
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.base64ToBlob = base64ToBlob;
9
+
10
+ require("core-js/modules/es.regexp.exec.js");
11
+
12
+ require("core-js/modules/es.string.match.js");
13
+
14
+ require("core-js/modules/es.array.iterator.js");
15
+
16
+ require("core-js/modules/es.array-buffer.slice.js");
17
+
18
+ require("core-js/modules/es.object.to-string.js");
19
+
20
+ require("core-js/modules/es.typed-array.uint8-array.js");
21
+
22
+ require("core-js/modules/es.typed-array.copy-within.js");
23
+
24
+ require("core-js/modules/es.typed-array.every.js");
25
+
26
+ require("core-js/modules/es.typed-array.fill.js");
27
+
28
+ require("core-js/modules/es.typed-array.filter.js");
29
+
30
+ require("core-js/modules/es.typed-array.find.js");
31
+
32
+ require("core-js/modules/es.typed-array.find-index.js");
33
+
34
+ require("core-js/modules/es.typed-array.for-each.js");
35
+
36
+ require("core-js/modules/es.typed-array.includes.js");
37
+
38
+ require("core-js/modules/es.typed-array.index-of.js");
39
+
40
+ require("core-js/modules/es.typed-array.iterator.js");
41
+
42
+ require("core-js/modules/es.typed-array.join.js");
43
+
44
+ require("core-js/modules/es.typed-array.last-index-of.js");
45
+
46
+ require("core-js/modules/es.typed-array.map.js");
47
+
48
+ require("core-js/modules/es.typed-array.reduce.js");
49
+
50
+ require("core-js/modules/es.typed-array.reduce-right.js");
51
+
52
+ require("core-js/modules/es.typed-array.reverse.js");
53
+
54
+ require("core-js/modules/es.typed-array.set.js");
55
+
56
+ require("core-js/modules/es.typed-array.slice.js");
57
+
58
+ require("core-js/modules/es.typed-array.some.js");
59
+
60
+ require("core-js/modules/es.typed-array.sort.js");
61
+
62
+ require("core-js/modules/es.typed-array.subarray.js");
63
+
64
+ require("core-js/modules/es.typed-array.to-locale-string.js");
65
+
66
+ require("core-js/modules/es.typed-array.to-string.js");
67
+
68
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
69
+
70
+ /**
71
+ * base64 转 blob
72
+ */
73
+ function base64ToBlob(base64, contentType) {
74
+ var _prefix$match;
75
+
76
+ var _base64$split = base64.split(','),
77
+ _base64$split2 = (0, _slicedToArray2.default)(_base64$split, 2),
78
+ prefix = _base64$split2[0],
79
+ rest = _base64$split2[1];
80
+
81
+ var type = contentType !== null && contentType !== void 0 ? contentType : (_prefix$match = prefix.match(/:(.*?);/)) === null || _prefix$match === void 0 ? void 0 : _prefix$match[1];
82
+ var data = window.atob(rest);
83
+ var len = data.length;
84
+ var u8arr = new Uint8Array(len);
85
+
86
+ while (len--) {
87
+ u8arr[len] = data.charCodeAt(len);
88
+ }
89
+
90
+ return new Blob([u8arr], {
91
+ type: type
92
+ });
93
+ }