util-helpers 4.0.6 → 4.2.0

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 (50) hide show
  1. package/README.md +10 -51
  2. package/dist/util-helpers.js +230 -64
  3. package/dist/util-helpers.min.js +1 -1
  4. package/dist/util-helpers.min.js.map +1 -1
  5. package/esm/blobToDataURL.js +43 -0
  6. package/esm/dataURLToBlob.js +31 -0
  7. package/esm/divide.js +17 -8
  8. package/esm/formatBankCard.js +1 -1
  9. package/esm/formatMoney.js +7 -5
  10. package/esm/index.js +11 -0
  11. package/esm/isBusinessLicense.js +2 -2
  12. package/esm/isSocialCreditCode.js +2 -2
  13. package/esm/minus.js +17 -8
  14. package/esm/parseIdCard.js +1 -1
  15. package/esm/plus.js +17 -8
  16. package/esm/replaceChar.js +1 -1
  17. package/esm/setDataURLPrefix.js +30 -0
  18. package/esm/times.js +17 -8
  19. package/esm/utils/convertToString.js +2 -11
  20. package/esm/utils/math.util.js +4 -5
  21. package/esm/waitTime.js +26 -0
  22. package/lib/blobToDataURL.js +51 -0
  23. package/lib/dataURLToBlob.js +39 -0
  24. package/lib/divide.js +29 -8
  25. package/lib/formatBankCard.js +1 -1
  26. package/lib/formatMoney.js +6 -5
  27. package/lib/index.js +32 -0
  28. package/lib/isBusinessLicense.js +2 -2
  29. package/lib/isSocialCreditCode.js +2 -2
  30. package/lib/minus.js +29 -8
  31. package/lib/parseIdCard.js +1 -1
  32. package/lib/plus.js +29 -8
  33. package/lib/replaceChar.js +1 -1
  34. package/lib/setDataURLPrefix.js +38 -0
  35. package/lib/times.js +29 -8
  36. package/lib/utils/convertToString.js +2 -12
  37. package/lib/utils/math.util.js +4 -3
  38. package/lib/waitTime.js +34 -0
  39. package/package.json +2 -2
  40. package/types/blobToDataURL.d.ts +25 -0
  41. package/types/dataURLToBlob.d.ts +15 -0
  42. package/types/divide.d.ts +2 -4
  43. package/types/index.d.ts +4 -0
  44. package/types/minus.d.ts +2 -4
  45. package/types/plus.d.ts +2 -4
  46. package/types/setDataURLPrefix.d.ts +25 -0
  47. package/types/times.d.ts +2 -4
  48. package/types/utils/convertToString.d.ts +2 -2
  49. package/types/utils/math.util.d.ts +7 -0
  50. package/types/waitTime.d.ts +20 -0
package/README.md CHANGED
@@ -44,12 +44,15 @@ formatMoney('1000'); // => 1,000.00
44
44
  - [divide](https://doly-dev.github.io/util-helpers/module-Math.html#.divide) - 除
45
45
  - [round](https://doly-dev.github.io/util-helpers/module-Math.html#.round) - 四舍五入
46
46
  - 数据处理
47
+ - [blobToDataURL](https://doly-dev.github.io/util-helpers/module-Processor.html#.blobToDataURL) - 将 Blob 或 File 对象转成 data:URL 格式的 Base64 字符串
47
48
  - [bytesToSize](https://doly-dev.github.io/util-helpers/module-Processor.html#.bytesToSize) - 字节转换为存储单位
49
+ - [dataURLToBlob](https://doly-dev.github.io/util-helpers/module-Processor.html#.dataURLToBlob) - 将 DataURL 转为 Blob 对象
48
50
  - [formatMoney](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMoney) - 金额格式化
49
51
  - [formatBankCard](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatBankCard) - 银行卡格式化
50
- - [replaceChar](https://doly-dev.github.io/util-helpers/module-Processor.html#.replaceChar) - 替换字符,应用场景如:脱敏
51
52
  - [numberToChinese](https://doly-dev.github.io/util-helpers/module-Processor.html#.numberToChinese) - 数字转中文数字
52
53
  - [parseIdCard](https://doly-dev.github.io/util-helpers/module-Processor.html#.parseIdCard) - 解析身份证号码
54
+ - [replaceChar](https://doly-dev.github.io/util-helpers/module-Processor.html#.replaceChar) - 替换字符,应用场景如:脱敏
55
+ - [setDataURLPrefix](https://doly-dev.github.io/util-helpers/module-Processor.html#.setDataURLPrefix) - 设置 DataURL 前缀、MIME 类型、base64 标识
53
56
  - 数据验证
54
57
  - [isMobile](https://doly-dev.github.io/util-helpers/module-Validator.html#.isMobile) - 手机号码
55
58
  - [isTelephone](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTelephone) - 固定电话
@@ -72,6 +75,8 @@ formatMoney('1000'); // => 1,000.00
72
75
  - [isUrl](https://doly-dev.github.io/util-helpers/module-Validator.html#.isUrl) - URL
73
76
  - [isBusinessLicense](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBusinessLicense) - 营业执照,也叫工商注册号
74
77
  - [validatePassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.validatePassword) - 验证密码
78
+ - 其他
79
+ - [waitTime](https://doly-dev.github.io/util-helpers/module-Other.html#.waitTime) - 等待时间返回 Promise
75
80
 
76
81
  ## 精选第三方工具库
77
82
 
@@ -87,56 +92,8 @@ formatMoney('1000'); // => 1,000.00
87
92
  - [tinycolor2] - JavaScript 颜色工具,用于 JavaScript 中的颜色处理和转换
88
93
  - [store2] - 丰富了 localStorage 和 sessionStorage 功能(JSON,命名空间,扩展等)
89
94
  - [uuid] - 生成通用唯一识别码(Universally Unique Identifier)
90
-
91
- ## 贡献
92
-
93
- ### commit 格式
94
-
95
- - **格式**
96
-
97
- ```bash
98
- type(scope?): subject
99
- ```
100
-
101
- - **示例**
102
-
103
- ```bash
104
- chore: run tests on travis ci
105
- fix(server): send cors headers
106
- feat(blog): add comment section
107
- ```
108
-
109
- - **type**
110
-
111
- | 值 | 说明 |
112
- | -------- | -------------------------------------------------------------------------------- |
113
- | build | 影响构建系统或外部依赖项的更新(示例范围:gulp, broccoli, npm) |
114
- | ci | 对 CI 配置文件和脚本的更改(例如 scopes: Travis, Circle, BrowserStack, SauceLabs) |
115
- | chore | 其他不修改 src 或测试文件的更改 |
116
- | docs | 只改变文档 |
117
- | feat | 新功能 |
118
- | fix | bug 修复 |
119
- | perf | 改进性能的代码更改 |
120
- | refactor | 既不修复 bug 也不添加新功能的代码更改 |
121
- | revert | 还原以前的提交 |
122
- | style | 不影响代码含义的更改(white-space、格式、缺少分号等) |
123
- | test | 添加缺失的测试或纠正现有的测试 |
124
-
125
- - **使用 `cz` 生成**
126
-
127
- > 格式参考 [What is commitlint]
128
-
129
- 原来使用 `git commit -m "xx"` 改为以下命令(交互方式填写提交信息):
130
-
131
- ```bash
132
- yarn commit
133
- ```
134
-
135
-
136
-
137
- ```bash
138
- npm run commit
139
- ```
95
+ - [JSZip] - 创建、读取和编辑 zip 文件
96
+ <!-- - [data-urls] - 根据 WHATWG Fetch 标准解析 Data URLs -->
140
97
 
141
98
  [lodash]: https://www.npmjs.com/package/lodash
142
99
  [query-string]: https://www.npmjs.com/package/query-string
@@ -150,6 +107,8 @@ npm run commit
150
107
  [tinycolor2]: https://www.npmjs.com/package/tinycolor2
151
108
  [store2]: https://www.npmjs.com/package/store2
152
109
  [uuid]: https://www.npmjs.com/package/uuid
110
+ [jszip]: https://www.npmjs.com/package/jszip
111
+ [data-urls]: https://www.npmjs.com/package/data-urls
153
112
  [npm]: https://img.shields.io/npm/v/util-helpers.svg
154
113
  [npm-url]: https://npmjs.com/package/util-helpers
155
114
  [what is commitlint]: https://github.com/conventional-changelog/commitlint#what-is-commitlint