@yelon/util 15.2.6 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +22 -22
  3. package/analysis/global-event.subject.d.ts +7 -7
  4. package/analysis/index.d.ts +1 -1
  5. package/array/array-type.service.d.ts +68 -68
  6. package/array/array.service.d.ts +78 -78
  7. package/array/index.d.ts +2 -2
  8. package/browser/cookie.service.d.ts +67 -67
  9. package/browser/copy.d.ts +6 -6
  10. package/browser/index.d.ts +5 -5
  11. package/browser/is-empty.d.ts +6 -6
  12. package/browser/scroll.service.d.ts +37 -37
  13. package/browser/style.d.ts +21 -21
  14. package/config/abc/date-picker.type.d.ts +52 -52
  15. package/config/abc/error-collect.type.d.ts +10 -10
  16. package/config/abc/exception.type.d.ts +9 -9
  17. package/config/abc/image.type.d.ts +15 -15
  18. package/config/abc/index.d.ts +17 -17
  19. package/config/abc/loading.type.d.ts +31 -31
  20. package/config/abc/lodop.type.d.ts +33 -33
  21. package/config/abc/media.type.d.ts +11 -11
  22. package/config/abc/onboarding.type.d.ts +4 -4
  23. package/config/abc/page-header.type.d.ts +39 -39
  24. package/config/abc/pdf.type.d.ts +35 -35
  25. package/config/abc/qr.type.d.ts +25 -25
  26. package/config/abc/se.type.d.ts +32 -32
  27. package/config/abc/sg.type.d.ts +10 -10
  28. package/config/abc/st.type.d.ts +465 -465
  29. package/config/abc/sv.type.d.ts +14 -14
  30. package/config/abc/xlsx.type.d.ts +12 -12
  31. package/config/abc/zip.type.d.ts +10 -10
  32. package/config/acl/acl.type.d.ts +32 -32
  33. package/config/auth/auth.type.d.ts +55 -55
  34. package/config/bis/bis.type.d.ts +7 -7
  35. package/config/cache/cache.type.d.ts +40 -40
  36. package/config/chart/chart.type.d.ts +33 -33
  37. package/config/config.service.d.ts +13 -13
  38. package/config/config.types.d.ts +48 -48
  39. package/config/index.d.ts +14 -14
  40. package/config/mock/mock.type.d.ts +18 -18
  41. package/config/sf/sf.type.d.ts +133 -133
  42. package/config/socket/socket.type.d.ts +4 -4
  43. package/config/theme/http.type.d.ts +14 -14
  44. package/config/theme/i18n.type.d.ts +14 -14
  45. package/config/theme/index.d.ts +3 -3
  46. package/config/theme/responsive.type.d.ts +12 -12
  47. package/config/util/array.type.d.ts +22 -22
  48. package/config/util/currency.type.d.ts +39 -39
  49. package/date-time/index.d.ts +2 -2
  50. package/date-time/picker.d.ts +68 -68
  51. package/date-time/time.d.ts +29 -29
  52. package/decorator/convert.d.ts +24 -24
  53. package/decorator/index.d.ts +2 -2
  54. package/decorator/zone-outside.d.ts +35 -35
  55. package/{esm2020 → esm2022}/analysis/analysis.mjs +4 -4
  56. package/esm2022/analysis/global-event.subject.mjs +18 -0
  57. package/{esm2020 → esm2022}/analysis/index.mjs +2 -2
  58. package/{esm2020 → esm2022}/array/array-type.service.mjs +1 -1
  59. package/{esm2020 → esm2022}/array/array.mjs +4 -4
  60. package/esm2022/array/array.service.mjs +278 -0
  61. package/{esm2020 → esm2022}/array/index.mjs +2 -2
  62. package/{esm2020 → esm2022}/browser/browser.mjs +4 -4
  63. package/esm2022/browser/cookie.service.mjs +104 -0
  64. package/{esm2020 → esm2022}/browser/copy.mjs +27 -27
  65. package/{esm2020 → esm2022}/browser/index.mjs +5 -5
  66. package/{esm2020 → esm2022}/browser/is-empty.mjs +18 -18
  67. package/esm2022/browser/scroll.service.mjs +89 -0
  68. package/{esm2020 → esm2022}/browser/style.mjs +37 -37
  69. package/{esm2020 → esm2022}/config/abc/date-picker.type.mjs +1 -1
  70. package/{esm2020 → esm2022}/config/abc/error-collect.type.mjs +1 -1
  71. package/{esm2020 → esm2022}/config/abc/exception.type.mjs +1 -1
  72. package/{esm2020 → esm2022}/config/abc/image.type.mjs +1 -1
  73. package/{esm2020 → esm2022}/config/abc/index.mjs +17 -17
  74. package/{esm2020 → esm2022}/config/abc/loading.type.mjs +1 -1
  75. package/{esm2020 → esm2022}/config/abc/lodop.type.mjs +1 -1
  76. package/{esm2020 → esm2022}/config/abc/media.type.mjs +1 -1
  77. package/{esm2020 → esm2022}/config/abc/onboarding.type.mjs +1 -1
  78. package/{esm2020 → esm2022}/config/abc/page-header.type.mjs +1 -1
  79. package/esm2022/config/abc/pdf.type.mjs +2 -0
  80. package/{esm2020 → esm2022}/config/abc/qr.type.mjs +1 -1
  81. package/{esm2020 → esm2022}/config/abc/se.type.mjs +1 -1
  82. package/{esm2020 → esm2022}/config/abc/sg.type.mjs +1 -1
  83. package/{esm2020 → esm2022}/config/abc/st.type.mjs +1 -1
  84. package/{esm2020 → esm2022}/config/abc/sv.type.mjs +2 -2
  85. package/{esm2020 → esm2022}/config/abc/xlsx.type.mjs +1 -1
  86. package/{esm2020 → esm2022}/config/abc/zip.type.mjs +1 -1
  87. package/{esm2020 → esm2022}/config/acl/acl.type.mjs +1 -1
  88. package/{esm2020 → esm2022}/config/auth/auth.type.mjs +1 -1
  89. package/{esm2020 → esm2022}/config/bis/bis.type.mjs +1 -1
  90. package/{esm2020 → esm2022}/config/cache/cache.type.mjs +1 -1
  91. package/{esm2020 → esm2022}/config/chart/chart.type.mjs +1 -1
  92. package/{esm2020 → esm2022}/config/config.mjs +4 -4
  93. package/esm2022/config/config.service.mjs +38 -0
  94. package/{esm2020 → esm2022}/config/config.types.mjs +8 -8
  95. package/{esm2020 → esm2022}/config/index.mjs +14 -14
  96. package/{esm2020 → esm2022}/config/mock/mock.type.mjs +1 -1
  97. package/{esm2020 → esm2022}/config/sf/sf.type.mjs +1 -1
  98. package/{esm2020 → esm2022}/config/socket/socket.type.mjs +1 -1
  99. package/{esm2020 → esm2022}/config/theme/http.type.mjs +1 -1
  100. package/{esm2020 → esm2022}/config/theme/i18n.type.mjs +1 -1
  101. package/{esm2020 → esm2022}/config/theme/index.mjs +3 -3
  102. package/{esm2020 → esm2022}/config/theme/responsive.type.mjs +1 -1
  103. package/{esm2020 → esm2022}/config/util/array.type.mjs +1 -1
  104. package/{esm2020 → esm2022}/config/util/currency.type.mjs +1 -1
  105. package/{esm2020 → esm2022}/date-time/date-time.mjs +4 -4
  106. package/{esm2020 → esm2022}/date-time/index.mjs +2 -2
  107. package/{esm2020 → esm2022}/date-time/picker.mjs +115 -115
  108. package/{esm2020 → esm2022}/date-time/time.mjs +88 -88
  109. package/{esm2020 → esm2022}/decorator/convert.mjs +57 -57
  110. package/{esm2020 → esm2022}/decorator/decorator.mjs +4 -4
  111. package/{esm2020 → esm2022}/decorator/index.mjs +2 -2
  112. package/{esm2020 → esm2022}/decorator/zone-outside.mjs +56 -56
  113. package/{esm2020 → esm2022}/form/form.mjs +4 -4
  114. package/{esm2020 → esm2022}/form/index.mjs +2 -2
  115. package/{esm2020 → esm2022}/form/match-control.mjs +29 -29
  116. package/{esm2020 → esm2022}/form/validators.mjs +80 -80
  117. package/esm2022/format/currency.service.mjs +239 -0
  118. package/{esm2020 → esm2022}/format/currency.types.mjs +7 -7
  119. package/{esm2020 → esm2022}/format/format.mjs +4 -4
  120. package/{esm2020 → esm2022}/format/index.mjs +4 -4
  121. package/{esm2020 → esm2022}/format/string.mjs +84 -84
  122. package/{esm2020 → esm2022}/format/validate.mjs +93 -93
  123. package/{esm2020 → esm2022}/index.mjs +12 -12
  124. package/{esm2020 → esm2022}/math/in-range.mjs +24 -24
  125. package/{esm2020 → esm2022}/math/index.mjs +2 -2
  126. package/{esm2020 → esm2022}/math/math.mjs +4 -4
  127. package/{esm2020 → esm2022}/math/round.mjs +52 -52
  128. package/{esm2020 → esm2022}/other/assert.mjs +66 -66
  129. package/{esm2020 → esm2022}/other/deep.mjs +77 -77
  130. package/{esm2020 → esm2022}/other/favicon.mjs +28 -28
  131. package/{esm2020 → esm2022}/other/index.mjs +7 -7
  132. package/esm2022/other/lazy.service.mjs +133 -0
  133. package/{esm2020 → esm2022}/other/logger.mjs +32 -32
  134. package/{esm2020 → esm2022}/other/other.mjs +4 -4
  135. package/esm2022/other/path-to-regexp.service.mjs +240 -0
  136. package/{esm2020 → esm2022}/other/resize.mjs +3 -3
  137. package/esm2022/pipes/currency/cny.pipe.mjs +24 -0
  138. package/{esm2020 → esm2022}/pipes/currency/index.mjs +4 -4
  139. package/esm2022/pipes/currency/mega.pipe.mjs +30 -0
  140. package/esm2022/pipes/currency/module.mjs +20 -0
  141. package/{esm2020 → esm2022}/pipes/currency/pipe-currency.mjs +4 -4
  142. package/esm2022/pipes/currency/price.pipe.mjs +28 -0
  143. package/esm2022/pipes/filter/filter.pipe.mjs +20 -0
  144. package/{esm2020 → esm2022}/pipes/filter/index.mjs +2 -2
  145. package/esm2022/pipes/filter/module.mjs +18 -0
  146. package/{esm2020 → esm2022}/pipes/filter/pipe-filter.mjs +4 -4
  147. package/{esm2020 → esm2022}/pipes/format/index.mjs +2 -2
  148. package/esm2022/pipes/format/mask.pipe.mjs +35 -0
  149. package/esm2022/pipes/format/module.mjs +18 -0
  150. package/{esm2020 → esm2022}/pipes/format/pipe-format.mjs +4 -4
  151. package/{esm2020 → esm2022}/pipes/index.mjs +3 -3
  152. package/{esm2020 → esm2022}/pipes/pipes.mjs +4 -4
  153. package/{esm2020 → esm2022}/token/index.mjs +2 -2
  154. package/{esm2020 → esm2022}/token/page-visibility.mjs +14 -14
  155. package/{esm2020 → esm2022}/token/token.mjs +4 -4
  156. package/{esm2020 → esm2022}/token/window.mjs +16 -16
  157. package/{esm2020 → esm2022}/yelon-util.mjs +4 -4
  158. package/{fesm2020 → fesm2022}/analysis.mjs +24 -24
  159. package/fesm2022/analysis.mjs.map +1 -0
  160. package/{fesm2020 → fesm2022}/array.mjs +284 -284
  161. package/{fesm2015 → fesm2022}/array.mjs.map +1 -1
  162. package/{fesm2020 → fesm2022}/browser.mjs +279 -279
  163. package/{fesm2020 → fesm2022}/browser.mjs.map +1 -1
  164. package/{fesm2020 → fesm2022}/config.mjs +54 -54
  165. package/{fesm2020 → fesm2022}/config.mjs.map +1 -1
  166. package/{fesm2020 → fesm2022}/date-time.mjs +211 -211
  167. package/{fesm2020 → fesm2022}/decorator.mjs +121 -121
  168. package/{fesm2020 → fesm2022}/form.mjs +118 -118
  169. package/{fesm2020 → fesm2022}/format.mjs +431 -431
  170. package/{fesm2020 → fesm2022}/format.mjs.map +1 -1
  171. package/{fesm2020 → fesm2022}/math.mjs +85 -85
  172. package/{fesm2020 → fesm2022}/other.mjs +586 -586
  173. package/{fesm2020 → fesm2022}/other.mjs.map +1 -1
  174. package/{fesm2020 → fesm2022}/pipe-currency.mjs +94 -94
  175. package/{fesm2020 → fesm2022}/pipe-currency.mjs.map +1 -1
  176. package/fesm2022/pipe-filter.mjs +40 -0
  177. package/{fesm2015 → fesm2022}/pipe-filter.mjs.map +1 -1
  178. package/{fesm2020 → fesm2022}/pipe-format.mjs +55 -55
  179. package/{fesm2015 → fesm2022}/pipe-format.mjs.map +1 -1
  180. package/{fesm2015 → fesm2022}/pipes.mjs +8 -8
  181. package/{fesm2020 → fesm2022}/token.mjs +37 -37
  182. package/{fesm2015 → fesm2022}/yelon-util.mjs +17 -17
  183. package/form/index.d.ts +2 -2
  184. package/form/match-control.d.ts +15 -15
  185. package/form/validators.d.ts +62 -62
  186. package/format/currency.service.d.ts +37 -37
  187. package/format/currency.types.d.ts +77 -77
  188. package/format/index.d.ts +4 -4
  189. package/format/string.d.ts +44 -44
  190. package/format/validate.d.ts +72 -72
  191. package/index.d.ts +12 -12
  192. package/math/in-range.d.ts +14 -14
  193. package/math/index.d.ts +2 -2
  194. package/math/round.d.ts +33 -33
  195. package/other/assert.d.ts +36 -36
  196. package/other/deep.d.ts +35 -35
  197. package/other/favicon.d.ts +2 -2
  198. package/other/index.d.ts +7 -7
  199. package/other/lazy.service.d.ts +48 -48
  200. package/other/logger.d.ts +5 -5
  201. package/other/path-to-regexp.service.d.ts +26 -26
  202. package/other/resize.d.ts +1 -1
  203. package/package.json +129 -165
  204. package/pipes/currency/cny.pipe.d.ts +15 -15
  205. package/pipes/currency/index.d.ts +4 -4
  206. package/pipes/currency/mega.pipe.d.ts +16 -16
  207. package/pipes/currency/module.d.ts +9 -9
  208. package/pipes/currency/price.pipe.d.ts +19 -19
  209. package/pipes/filter/filter.pipe.d.ts +13 -13
  210. package/pipes/filter/index.d.ts +2 -2
  211. package/pipes/filter/module.d.ts +7 -7
  212. package/pipes/format/index.d.ts +2 -2
  213. package/pipes/format/mask.pipe.d.ts +27 -27
  214. package/pipes/format/module.d.ts +7 -7
  215. package/pipes/index.d.ts +3 -3
  216. package/token/index.d.ts +2 -2
  217. package/token/page-visibility.d.ts +8 -8
  218. package/token/window.d.ts +7 -7
  219. package/esm2020/analysis/global-event.subject.mjs +0 -17
  220. package/esm2020/array/array.service.mjs +0 -277
  221. package/esm2020/browser/cookie.service.mjs +0 -103
  222. package/esm2020/browser/scroll.service.mjs +0 -88
  223. package/esm2020/config/abc/pdf.type.mjs +0 -2
  224. package/esm2020/config/config.service.mjs +0 -37
  225. package/esm2020/format/currency.service.mjs +0 -238
  226. package/esm2020/other/lazy.service.mjs +0 -132
  227. package/esm2020/other/path-to-regexp.service.mjs +0 -239
  228. package/esm2020/pipes/currency/cny.pipe.mjs +0 -23
  229. package/esm2020/pipes/currency/mega.pipe.mjs +0 -29
  230. package/esm2020/pipes/currency/module.mjs +0 -19
  231. package/esm2020/pipes/currency/price.pipe.mjs +0 -27
  232. package/esm2020/pipes/filter/filter.pipe.mjs +0 -19
  233. package/esm2020/pipes/filter/module.mjs +0 -17
  234. package/esm2020/pipes/format/mask.pipe.mjs +0 -34
  235. package/esm2020/pipes/format/module.mjs +0 -17
  236. package/fesm2015/analysis.mjs +0 -24
  237. package/fesm2015/analysis.mjs.map +0 -1
  238. package/fesm2015/array.mjs +0 -254
  239. package/fesm2015/browser.mjs +0 -283
  240. package/fesm2015/browser.mjs.map +0 -1
  241. package/fesm2015/config.mjs +0 -56
  242. package/fesm2015/config.mjs.map +0 -1
  243. package/fesm2015/date-time.mjs +0 -207
  244. package/fesm2015/date-time.mjs.map +0 -1
  245. package/fesm2015/decorator.mjs +0 -121
  246. package/fesm2015/decorator.mjs.map +0 -1
  247. package/fesm2015/form.mjs +0 -118
  248. package/fesm2015/format.mjs +0 -413
  249. package/fesm2015/format.mjs.map +0 -1
  250. package/fesm2015/math.mjs +0 -85
  251. package/fesm2015/other.mjs +0 -589
  252. package/fesm2015/other.mjs.map +0 -1
  253. package/fesm2015/pipe-currency.mjs +0 -96
  254. package/fesm2015/pipe-currency.mjs.map +0 -1
  255. package/fesm2015/pipe-filter.mjs +0 -40
  256. package/fesm2015/pipe-format.mjs +0 -55
  257. package/fesm2015/token.mjs +0 -37
  258. package/fesm2020/analysis.mjs.map +0 -1
  259. package/fesm2020/array.mjs.map +0 -1
  260. package/fesm2020/form.mjs.map +0 -1
  261. package/fesm2020/math.mjs.map +0 -1
  262. package/fesm2020/pipe-filter.mjs +0 -40
  263. package/fesm2020/pipe-filter.mjs.map +0 -1
  264. package/fesm2020/pipe-format.mjs.map +0 -1
  265. package/fesm2020/pipes.mjs +0 -8
  266. package/fesm2020/pipes.mjs.map +0 -1
  267. package/fesm2020/token.mjs.map +0 -1
  268. package/fesm2020/yelon-util.mjs +0 -17
  269. package/fesm2020/yelon-util.mjs.map +0 -1
  270. /package/{fesm2020 → fesm2022}/date-time.mjs.map +0 -0
  271. /package/{fesm2020 → fesm2022}/decorator.mjs.map +0 -0
  272. /package/{fesm2015 → fesm2022}/form.mjs.map +0 -0
  273. /package/{fesm2015 → fesm2022}/math.mjs.map +0 -0
  274. /package/{fesm2015 → fesm2022}/pipes.mjs.map +0 -0
  275. /package/{fesm2015 → fesm2022}/token.mjs.map +0 -0
  276. /package/{fesm2015 → fesm2022}/yelon-util.mjs.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"format.mjs","sources":["../../../../packages/util/format/string.ts","../../../../packages/util/format/validate.ts","../../../../packages/util/format/currency.types.ts","../../../../packages/util/format/currency.service.ts","../../../../packages/util/format/format.ts"],"sourcesContent":["import { deepGet } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n/**\n * String formatting\n *\n * 字符串格式化\n * ```\n * format('this is ${name}', { name: 'asdf' })\n * // output: this is asdf\n * format('this is ${user.name}', { user: { name: 'asdf' } }, true)\n * // output: this is asdf\n * ```\n */\nexport function format(\n str: string | null | undefined,\n obj: NzSafeAny | null | undefined,\n needDeepGet: boolean = false\n): string {\n return (str || '').replace(/\\${([^}]+)}/g, (_work: string, key: string) =>\n needDeepGet ? deepGet(obj, key.split('.'), '') : (obj || {})[key] || ''\n );\n}\n\nexport interface FormatMaskOption {\n mask: string;\n tokens?: { [key: string]: FormatMaskToken };\n}\n\nexport interface FormatMaskToken {\n pattern: RegExp;\n default?: NzSafeAny;\n transform?: (char: string) => string;\n}\n\n/**\n * Format mask\n *\n * 格式化掩码\n *\n * | 字符 | 描述 |\n * | --- | --- |\n * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |\n * | `9` | 任意数字 |\n * | `#` | 任意字符 |\n * | `U` | 转换大写 |\n * | `L` | 转换小写 |\n * | `*` | 转换为 `*` 字符 |\n *\n * ```ts\n * formatMask('123', '(###)') => (123)\n * formatMask('15900000000', '999****9999') => 159****0000\n * ```\n */\nexport function formatMask(value: string, option: string | FormatMaskOption): string {\n if (!value) {\n return '';\n }\n const opt: FormatMaskOption = {\n ...(typeof option === 'string' ? { mask: option } : option)\n };\n const tokens: { [key: string]: FormatMaskToken } = {\n '0': { pattern: /\\d/, default: '0' },\n '9': { pattern: /\\d/ },\n '#': { pattern: /[a-zA-Z0-9]/ },\n U: {\n pattern: /[a-zA-Z]/,\n transform: char => char.toLocaleUpperCase()\n },\n L: {\n pattern: /[a-zA-Z]/,\n transform: char => char.toLocaleLowerCase()\n },\n '*': {\n pattern: /.*/,\n transform: _ => `*`\n },\n ...opt.tokens\n };\n\n const splitValue = value.split('');\n return opt.mask\n .split('')\n .reduce((res, cur) => {\n const token = tokens[cur];\n if (!token) {\n res.push(cur);\n return res;\n }\n\n const value = splitValue.shift() ?? '';\n if (!token.pattern.test(value)) {\n if (token.default) res.push(token.default);\n return res;\n }\n\n if (typeof token.transform === 'function') {\n res.push(token.transform(value));\n } else {\n res.push(value);\n }\n return res;\n }, [] as string[])\n .join('');\n}\n","export const REGEX_STR = {\n num: `(([-+]?\\\\d+\\\\.\\\\d+)|([-+]?\\\\d+)|([-+]?\\\\.\\\\d+))(?:[eE]([-+]?\\\\d+))?`,\n idCard: `(^\\\\d{15}$)|(^\\\\d{17}(?:[0-9]|X)$)`,\n mobile: `^(0|\\\\+?86|17951)?1[0-9]{10}$`,\n url: `(((^https?:(?:\\/\\/)?)(?:[-;:&=\\\\+\\\\$,\\\\w]+@)?[A-Za-z0-9.-]+(?::\\\\d+)?|(?:www.|[-;:&=\\\\+\\\\$,\\\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\\\+~%\\\\/.\\\\w-_]*)?\\\\??(?:[-\\\\+=&;%@.\\\\w_]*)#?(?:[\\\\w]*))?)`,\n ip: `(?:^(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}$)|(?:^(?:(?:[a-fA-F\\\\d]{1,4}:){7}(?:[a-fA-F\\\\d]{1,4}|:)|(?:[a-fA-F\\\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|:[a-fA-F\\\\d]{1,4}|:)|(?:[a-fA-F\\\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|(?::[a-fA-F\\\\d]{1,4}){1,2}|:)|(?:[a-fA-F\\\\d]{1,4}:){4}(?:(?::[a-fA-F\\\\d]{1,4}){0,1}:(?:25[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\\u4e00-\\u9fa5]+`\n};\n\nfunction genRegex(str: string, flags?: string): RegExp {\n return new RegExp(`^${str}$`, flags);\n}\n\nexport const REGEX = {\n num: genRegex(REGEX_STR.num),\n idCard: genRegex(REGEX_STR.idCard, 'i'),\n mobile: genRegex(REGEX_STR.mobile),\n url: genRegex(REGEX_STR.url),\n ip: genRegex(REGEX_STR.ip),\n color: genRegex(REGEX_STR.color),\n chinese: genRegex(REGEX_STR.chinese)\n};\n\n/**\n * Wheter is number\n *\n * 是否为数字\n */\nexport function isNum(value: string | number): boolean {\n return REGEX.num.test(value.toString());\n}\n\n/**\n * Wheter is integer\n *\n * 是否为整数\n */\nexport function isInt(value: string | number): boolean {\n return isNum(value) && parseInt(value.toString(), 10).toString() === value.toString();\n}\n\n/**\n * Wheter is decimal\n *\n * 是否为小数点数值\n */\nexport function isDecimal(value: string | number): boolean {\n return isNum(value) && !isInt(value);\n}\n\n/**\n * Wheter is People's Republic of China identity card\n *\n * 是否为中华人民共和国居民身份证\n */\nexport function isIdCard(value: string): boolean {\n return REGEX.idCard.test(value);\n}\n\n/**\n * Wheter is china mobile (China)\n *\n * 是否为手机号(中国)\n */\nexport function isMobile(value: string): boolean {\n return REGEX.mobile.test(value);\n}\n\n/**\n * Wheter is url address\n *\n * 是否URL地址\n */\nexport function isUrl(url: string): boolean {\n return REGEX.url.test(url);\n}\n\n/**\n * Wheter is IPv4 address (Support v4, v6)\n *\n * 是否IP4地址(支持v4、v6)\n */\nexport function isIp(ip: string): boolean {\n return REGEX.ip.test(ip);\n}\n\n/**\n * Wheter is color\n *\n * 是否颜色代码值\n */\nexport function isColor(color: string): boolean {\n return REGEX.color.test(color);\n}\n\n/**\n * Wheter is chinese\n *\n * 是否中文\n */\nexport function isChinese(value: string): boolean {\n return REGEX.chinese.test(value);\n}\n","export type CurrencyStartingUnit = 'yuan' | 'cent';\n\nexport interface CurrencyStartingUnitOptions {\n /**\n * The starting unit of the value, `yuan` means 元, `cent` means 分, default: `yuan`\n *\n * 值的起始单位,`yuan` 元,`cent` 分,默认:`yuan`\n */\n startingUnit?: CurrencyStartingUnit;\n}\n\nexport interface CurrencyFormatOptions extends CurrencyStartingUnitOptions {\n /**\n * Using `DEFAULT_CURRENCY_CODE` when value is `true\n *\n * 是否使用 `CurrencyPipe` 来替代\n */\n useAngular?: boolean;\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n /**\n * 是否忽略精度 `.0` 或 `.00` 结尾的字符,默认:`true`\n */\n ignoreZeroPrecision?: boolean;\n\n /**\n * Use anguar `currency` pipe parse when is set, pls refer to [document](https://angular.io/api/common/CurrencyPipe)\n *\n * 若指定则表示使用 Angular 自带的 `currency` 管道来解析,见[文档](https://angular.cn/api/common/CurrencyPipe)\n */\n ngCurrency?: {\n display: 'code' | 'symbol' | 'symbol-narrow';\n currencyCode?: string;\n digitsInfo?: string;\n locale?: string;\n };\n}\n\nexport interface CurrencyMegaOptions extends CurrencyStartingUnitOptions {\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n\n /**\n * 单位国际化,默认:`{Q: '京', T: '兆', B: '亿', M: '万', K: '千',}`\n */\n unitI18n?: CurrencyMegaUnitI18n;\n}\n\nexport interface CurrencyMegaResult {\n raw: number | string;\n value: string;\n unit: string;\n unitI18n: string;\n}\n\nexport const CurrencyMega_Powers = [\n { unit: 'Q', value: Math.pow(10, 15) },\n { unit: 'T', value: Math.pow(10, 12) },\n { unit: 'B', value: Math.pow(10, 9) },\n { unit: 'M', value: Math.pow(10, 6) },\n { unit: 'K', value: 1000 }\n];\n\nexport interface CurrencyMegaUnitI18n {\n Q: string;\n T: string;\n B: string;\n M: string;\n K: string;\n}\n\nexport interface CurrencyCNYOptions extends CurrencyStartingUnitOptions {\n /**\n * Whether to return to uppercase notation, default: `true`\n *\n * 是否返回大写表示法,默认:`true`\n */\n inWords?: boolean;\n /**\n * Specify negative sign, default: `negative`\n *\n * 指定负数符号,默认:`负`\n */\n minusSymbol?: string;\n}\n","import { CurrencyPipe, formatNumber } from '@angular/common';\nimport { DEFAULT_CURRENCY_CODE, Inject, Injectable, LOCALE_ID } from '@angular/core';\n\nimport { YunzaiConfigService, YunzaiUtilCurrencyConfig } from '@yelon/util/config';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport {\n CurrencyCNYOptions,\n CurrencyFormatOptions,\n CurrencyMegaOptions,\n CurrencyMegaResult,\n CurrencyMega_Powers\n} from './currency.types';\n\n@Injectable({ providedIn: 'root' })\nexport class CurrencyService {\n private c: YunzaiUtilCurrencyConfig;\n private readonly currencyPipe: CurrencyPipe;\n\n constructor(\n cog: YunzaiConfigService,\n @Inject(LOCALE_ID) private locale: string,\n @Inject(DEFAULT_CURRENCY_CODE) _defaultCurrencyCode: string = 'USD'\n ) {\n this.currencyPipe = new CurrencyPipe(locale, _defaultCurrencyCode);\n this.c = cog.merge('utilCurrency', {\n startingUnit: 'yuan',\n megaUnit: { Q: '京', T: '兆', B: '亿', M: '万', K: '千' },\n precision: 2,\n ignoreZeroPrecision: true\n })!;\n }\n\n /**\n * Format a number with commas as thousands separators\n *\n * 格式化货币,用逗号将数字格式化为千位分隔符\n * ```ts\n * 10000 => `10,000`\n * 10000.567 => `10,000.57`\n * ```\n */\n format(value: number | string, options?: CurrencyFormatOptions): string {\n options = {\n startingUnit: this.c.startingUnit,\n precision: this.c.precision,\n ignoreZeroPrecision: this.c.ignoreZeroPrecision,\n ngCurrency: this.c.ngCurrency,\n ...options\n };\n let truthValue = Number(value);\n if (value == null || isNaN(truthValue)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n truthValue = truthValue / 100;\n }\n if (options.ngCurrency != null) {\n const cur = options.ngCurrency!;\n return this.currencyPipe.transform(\n truthValue,\n cur.currencyCode,\n cur.display,\n cur.digitsInfo,\n cur.locale || this.locale\n )!;\n }\n const res = formatNumber(\n truthValue,\n this.locale,\n `.${options.ignoreZeroPrecision ? 1 : options.precision}-${options.precision}`\n );\n return options.ignoreZeroPrecision ? res.replace(/(?:\\.[0]+)$/g, '') : res;\n }\n\n /**\n * Large number format filter\n *\n * 大数据格式化\n * ```ts\n * 1000 => { value: '1', unit: 'K', unitI18n: '千' }\n * 12456 => { value: '12.46', unit: 'K', unitI18n: '千' }\n * ```\n */\n mega(value: number | string, options?: CurrencyMegaOptions): CurrencyMegaResult {\n options = { precision: this.c.precision, unitI18n: this.c.megaUnit, startingUnit: this.c.startingUnit, ...options };\n let num = Number(value);\n const res: CurrencyMegaResult = { raw: value, value: '', unit: '', unitI18n: '' };\n if (isNaN(num) || num === 0) {\n res.value = value.toString();\n return res;\n }\n if (options.startingUnit === 'cent') {\n num = num / 100;\n }\n let abs = Math.abs(+num);\n const rounder = Math.pow(10, options.precision!);\n const isNegative = num < 0;\n for (const p of CurrencyMega_Powers) {\n let reduced = abs / p.value;\n\n reduced = Math.round(reduced * rounder) / rounder;\n\n if (reduced >= 1) {\n abs = reduced;\n res.unit = p.unit;\n break;\n }\n }\n\n res.value = (isNegative ? '-' : '') + abs;\n res.unitI18n = (options.unitI18n as { [key: string]: NzSafeAny })[res.unit];\n return res;\n }\n\n /**\n * Converted into RMB notation.\n *\n * 转化成人民币表示法\n */\n cny(value: number | string, options?: CurrencyCNYOptions): string {\n options = {\n inWords: true,\n minusSymbol: '负',\n startingUnit: this.c.startingUnit,\n ...options\n };\n\n value = Number(value);\n if (isNaN(value)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n value = value / 100;\n }\n value = value.toString();\n let integer: number | string;\n let decimal: number | string | null;\n [integer, decimal] = value.split('.');\n let symbol = '';\n if (integer.startsWith('-')) {\n symbol = options.minusSymbol!;\n integer = integer.substring(1);\n }\n if (/^-?\\d+$/.test(value)) {\n decimal = null;\n }\n integer = (+integer).toString();\n const inWords = options.inWords;\n const unit: { [key: string]: string[] } = {\n num: inWords\n ? ['', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '点']\n : ['', '一', '二', '三', '四', '五', '六', '七', '八', '九', '点'],\n radice: inWords\n ? [\n '',\n '拾',\n '佰',\n '仟',\n '万',\n '拾',\n '佰',\n '仟',\n '亿',\n '拾',\n '佰',\n '仟',\n '万亿',\n '拾',\n '佰',\n '仟',\n '兆',\n '拾',\n '佰',\n '仟'\n ]\n : [\n '',\n '十',\n '百',\n '千',\n '万',\n '十',\n '百',\n '千',\n '亿',\n '十',\n '百',\n '千',\n '万亿',\n '十',\n '百',\n '千',\n '兆',\n '十',\n '百',\n '千'\n ],\n dec: ['角', '分', '厘', '毫']\n };\n if (inWords) {\n value = (+value).toFixed(5).toString();\n }\n let integerRes = '';\n const integerCount = integer.length;\n if (integer === '0' || integerCount === 0) {\n integerRes = '零';\n } else {\n let cnDesc = '';\n for (let i = 0; i < integerCount; i++) {\n const n = +integer[i];\n const j = integerCount - i - 1;\n const isZero = i > 1 && n !== 0 && integer[i - 1] === '0';\n const cnZero = isZero ? '零' : '';\n const isEmpptyUnit = (n === 0 && j % 4 !== 0) || integer.substring(i - 3, i - 3 + 4) === '0000';\n const descMark = cnDesc;\n let cnNum = unit.num[n];\n\n cnDesc = isEmpptyUnit ? '' : unit.radice[j];\n // 第一位是一十\n if (i === 0 && cnNum === '一' && cnDesc === '十') cnNum = '';\n const isChangeEr =\n n > 1 &&\n cnNum === '二' && // 去除首位\n ['', '十', '百'].indexOf(cnDesc) === -1 && // 不读两\\两十\\两百\n descMark !== '十'; // 不读十两\n if (isChangeEr) cnNum = '两';\n integerRes += cnZero + cnNum + cnDesc;\n }\n }\n\n // 小数部分拼接\n let decimalRes = '';\n const decimalCount = decimal ? decimal.toString().length : 0;\n if (decimal === null) {\n decimalRes = inWords ? '整' : '';\n } else if (decimal === '0') {\n decimalRes = '零';\n } else {\n for (let i = 0; i < decimalCount; i++) {\n if (inWords && i > unit.dec.length - 1) break;\n const n = decimal[i];\n const cnZero = n === '0' ? '零' : '';\n const cnNum = unit.num[+n];\n const cnDesc = inWords ? unit.dec[i] : '';\n decimalRes += cnZero + cnNum + cnDesc;\n }\n }\n const ret =\n symbol +\n (inWords\n ? integerRes + (decimalRes === '零' ? '元整' : `元${decimalRes}`)\n : integerRes + (decimalRes === '' ? '' : `点${decimalRes}`));\n return ret;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGA;;;;;;;;;;AAUG;AACG,SAAU,MAAM,CACpB,GAA8B,EAC9B,GAAiC,EACjC,cAAuB,KAAK,EAAA;IAE5B,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,KAAa,EAAE,GAAW,KACpE,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,CACxE,CAAC;AACJ,CAAC;AAaD;;;;;;;;;;;;;;;;;;AAkBG;AACa,SAAA,UAAU,CAAC,KAAa,EAAE,MAAiC,EAAA;IACzE,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,EAAE,CAAC;AACX,KAAA;AACD,IAAA,MAAM,GAAG,GAAqB;AAC5B,QAAA,IAAI,OAAO,MAAM,KAAK,QAAQ,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;KAC5D,CAAC;AACF,IAAA,MAAM,MAAM,GAAuC;QACjD,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE;AACpC,QAAA,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;AACtB,QAAA,GAAG,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;AAC/B,QAAA,CAAC,EAAE;AACD,YAAA,OAAO,EAAE,UAAU;YACnB,SAAS,EAAE,IAAI,IAAI,IAAI,CAAC,iBAAiB,EAAE;AAC5C,SAAA;AACD,QAAA,CAAC,EAAE;AACD,YAAA,OAAO,EAAE,UAAU;YACnB,SAAS,EAAE,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;;4GA/OU,eAAe,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,mBAAA,EAAA,EAAA,EAAA,KAAA,EAMhB,SAAS,EAAA,EAAA,EAAA,KAAA,EACT,qBAAqB,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAPpB,eAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cADF,MAAM,EAAA,CAAA,CAAA;2FACnB,eAAe,EAAA,UAAA,EAAA,CAAA;kBAD3B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAO7B,MAAM;2BAAC,SAAS,CAAA;;0BAChB,MAAM;2BAAC,qBAAqB,CAAA;;;ACtBjC;;AAEG;;;;"}
1
+ {"version":3,"file":"format.mjs","sources":["../../../../packages/util/format/string.ts","../../../../packages/util/format/validate.ts","../../../../packages/util/format/currency.types.ts","../../../../packages/util/format/currency.service.ts","../../../../packages/util/format/format.ts"],"sourcesContent":["import { deepGet } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n/**\n * String formatting\n *\n * 字符串格式化\n * ```\n * format('this is ${name}', { name: 'asdf' })\n * // output: this is asdf\n * format('this is ${user.name}', { user: { name: 'asdf' } }, true)\n * // output: this is asdf\n * ```\n */\nexport function format(\n str: string | null | undefined,\n obj: NzSafeAny | null | undefined,\n needDeepGet: boolean = false\n): string {\n return (str || '').replace(/\\${([^}]+)}/g, (_work: string, key: string) =>\n needDeepGet ? deepGet(obj, key.split('.'), '') : (obj || {})[key] || ''\n );\n}\n\nexport interface FormatMaskOption {\n mask: string;\n tokens?: { [key: string]: FormatMaskToken };\n}\n\nexport interface FormatMaskToken {\n pattern: RegExp;\n default?: NzSafeAny;\n transform?: (char: string) => string;\n}\n\n/**\n * Format mask\n *\n * 格式化掩码\n *\n * | 字符 | 描述 |\n * | --- | --- |\n * | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |\n * | `9` | 任意数字 |\n * | `#` | 任意字符 |\n * | `U` | 转换大写 |\n * | `L` | 转换小写 |\n * | `*` | 转换为 `*` 字符 |\n *\n * ```ts\n * formatMask('123', '(###)') => (123)\n * formatMask('15900000000', '999****9999') => 159****0000\n * ```\n */\nexport function formatMask(value: string, option: string | FormatMaskOption): string {\n if (!value) {\n return '';\n }\n const opt: FormatMaskOption = {\n ...(typeof option === 'string' ? { mask: option } : option)\n };\n const tokens: { [key: string]: FormatMaskToken } = {\n '0': { pattern: /\\d/, default: '0' },\n '9': { pattern: /\\d/ },\n '#': { pattern: /[a-zA-Z0-9]/ },\n U: {\n pattern: /[a-zA-Z]/,\n transform: char => char.toLocaleUpperCase()\n },\n L: {\n pattern: /[a-zA-Z]/,\n transform: char => char.toLocaleLowerCase()\n },\n '*': {\n pattern: /.*/,\n transform: _ => `*`\n },\n ...opt.tokens\n };\n\n const splitValue = value.split('');\n return opt.mask\n .split('')\n .reduce((res, cur) => {\n const token = tokens[cur];\n if (!token) {\n res.push(cur);\n return res;\n }\n\n const value = splitValue.shift() ?? '';\n if (!token.pattern.test(value)) {\n if (token.default) res.push(token.default);\n return res;\n }\n\n if (typeof token.transform === 'function') {\n res.push(token.transform(value));\n } else {\n res.push(value);\n }\n return res;\n }, [] as string[])\n .join('');\n}\n","export const REGEX_STR = {\n num: `(([-+]?\\\\d+\\\\.\\\\d+)|([-+]?\\\\d+)|([-+]?\\\\.\\\\d+))(?:[eE]([-+]?\\\\d+))?`,\n idCard: `(^\\\\d{15}$)|(^\\\\d{17}(?:[0-9]|X)$)`,\n mobile: `^(0|\\\\+?86|17951)?1[0-9]{10}$`,\n url: `(((^https?:(?:\\/\\/)?)(?:[-;:&=\\\\+\\\\$,\\\\w]+@)?[A-Za-z0-9.-]+(?::\\\\d+)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-F\\\\d]{1,4}){1,4}|:)|(?:[a-fA-F\\\\d]{1,4}:){2}(?:(?::[a-fA-F\\\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|(?::[a-fA-F\\\\d]{1,4}){1,5}|:)|(?:[a-fA-F\\\\d]{1,4}:){1}(?:(?::[a-fA-F\\\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|(?::[a-fA-F\\\\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\\\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)){3}|(?::[a-fA-F\\\\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)`,\n color: `(?:#|0x)(?:[a-f0-9]{3}|[a-f0-9]{6})\\\\b|(?:rgb|hsl)a?\\\\([^\\\\)]*\\\\)`,\n chinese: `[\\u4e00-\\u9fa5]+`\n};\n\nfunction genRegex(str: string, flags?: string): RegExp {\n return new RegExp(`^${str}$`, flags);\n}\n\nexport const REGEX = {\n num: genRegex(REGEX_STR.num),\n idCard: genRegex(REGEX_STR.idCard, 'i'),\n mobile: genRegex(REGEX_STR.mobile),\n url: genRegex(REGEX_STR.url),\n ip: genRegex(REGEX_STR.ip),\n color: genRegex(REGEX_STR.color),\n chinese: genRegex(REGEX_STR.chinese)\n};\n\n/**\n * Wheter is number\n *\n * 是否为数字\n */\nexport function isNum(value: string | number): boolean {\n return REGEX.num.test(value.toString());\n}\n\n/**\n * Wheter is integer\n *\n * 是否为整数\n */\nexport function isInt(value: string | number): boolean {\n return isNum(value) && parseInt(value.toString(), 10).toString() === value.toString();\n}\n\n/**\n * Wheter is decimal\n *\n * 是否为小数点数值\n */\nexport function isDecimal(value: string | number): boolean {\n return isNum(value) && !isInt(value);\n}\n\n/**\n * Wheter is People's Republic of China identity card\n *\n * 是否为中华人民共和国居民身份证\n */\nexport function isIdCard(value: string): boolean {\n return REGEX.idCard.test(value);\n}\n\n/**\n * Wheter is china mobile (China)\n *\n * 是否为手机号(中国)\n */\nexport function isMobile(value: string): boolean {\n return REGEX.mobile.test(value);\n}\n\n/**\n * Wheter is url address\n *\n * 是否URL地址\n */\nexport function isUrl(url: string): boolean {\n return REGEX.url.test(url);\n}\n\n/**\n * Wheter is IPv4 address (Support v4, v6)\n *\n * 是否IP4地址(支持v4、v6)\n */\nexport function isIp(ip: string): boolean {\n return REGEX.ip.test(ip);\n}\n\n/**\n * Wheter is color\n *\n * 是否颜色代码值\n */\nexport function isColor(color: string): boolean {\n return REGEX.color.test(color);\n}\n\n/**\n * Wheter is chinese\n *\n * 是否中文\n */\nexport function isChinese(value: string): boolean {\n return REGEX.chinese.test(value);\n}\n","export type CurrencyStartingUnit = 'yuan' | 'cent';\n\nexport interface CurrencyStartingUnitOptions {\n /**\n * The starting unit of the value, `yuan` means 元, `cent` means 分, default: `yuan`\n *\n * 值的起始单位,`yuan` 元,`cent` 分,默认:`yuan`\n */\n startingUnit?: CurrencyStartingUnit;\n}\n\nexport interface CurrencyFormatOptions extends CurrencyStartingUnitOptions {\n /**\n * Using `DEFAULT_CURRENCY_CODE` when value is `true\n *\n * 是否使用 `CurrencyPipe` 来替代\n */\n useAngular?: boolean;\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n /**\n * 是否忽略精度 `.0` 或 `.00` 结尾的字符,默认:`true`\n */\n ignoreZeroPrecision?: boolean;\n\n /**\n * Use anguar `currency` pipe parse when is set, pls refer to [document](https://angular.io/api/common/CurrencyPipe)\n *\n * 若指定则表示使用 Angular 自带的 `currency` 管道来解析,见[文档](https://angular.cn/api/common/CurrencyPipe)\n */\n ngCurrency?: {\n display: 'code' | 'symbol' | 'symbol-narrow';\n currencyCode?: string;\n digitsInfo?: string;\n locale?: string;\n };\n}\n\nexport interface CurrencyMegaOptions extends CurrencyStartingUnitOptions {\n /**\n * 精度,默认:`2`\n */\n precision?: number;\n\n /**\n * 单位国际化,默认:`{Q: '京', T: '兆', B: '亿', M: '万', K: '千',}`\n */\n unitI18n?: CurrencyMegaUnitI18n;\n}\n\nexport interface CurrencyMegaResult {\n raw: number | string;\n value: string;\n unit: string;\n unitI18n: string;\n}\n\nexport const CurrencyMega_Powers = [\n { unit: 'Q', value: Math.pow(10, 15) },\n { unit: 'T', value: Math.pow(10, 12) },\n { unit: 'B', value: Math.pow(10, 9) },\n { unit: 'M', value: Math.pow(10, 6) },\n { unit: 'K', value: 1000 }\n];\n\nexport interface CurrencyMegaUnitI18n {\n Q: string;\n T: string;\n B: string;\n M: string;\n K: string;\n}\n\nexport interface CurrencyCNYOptions extends CurrencyStartingUnitOptions {\n /**\n * Whether to return to uppercase notation, default: `true`\n *\n * 是否返回大写表示法,默认:`true`\n */\n inWords?: boolean;\n /**\n * Specify negative sign, default: `negative`\n *\n * 指定负数符号,默认:`负`\n */\n minusSymbol?: string;\n}\n","import { CurrencyPipe, formatNumber } from '@angular/common';\nimport { DEFAULT_CURRENCY_CODE, Inject, Injectable, LOCALE_ID } from '@angular/core';\n\nimport { YunzaiConfigService, YunzaiUtilCurrencyConfig } from '@yelon/util/config';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport {\n CurrencyCNYOptions,\n CurrencyFormatOptions,\n CurrencyMegaOptions,\n CurrencyMegaResult,\n CurrencyMega_Powers\n} from './currency.types';\n\n@Injectable({ providedIn: 'root' })\nexport class CurrencyService {\n private c: YunzaiUtilCurrencyConfig;\n private readonly currencyPipe: CurrencyPipe;\n\n constructor(\n cog: YunzaiConfigService,\n @Inject(LOCALE_ID) private locale: string,\n @Inject(DEFAULT_CURRENCY_CODE) _defaultCurrencyCode: string = 'USD'\n ) {\n this.currencyPipe = new CurrencyPipe(locale, _defaultCurrencyCode);\n this.c = cog.merge('utilCurrency', {\n startingUnit: 'yuan',\n megaUnit: { Q: '京', T: '兆', B: '亿', M: '万', K: '千' },\n precision: 2,\n ignoreZeroPrecision: true\n })!;\n }\n\n /**\n * Format a number with commas as thousands separators\n *\n * 格式化货币,用逗号将数字格式化为千位分隔符\n * ```ts\n * 10000 => `10,000`\n * 10000.567 => `10,000.57`\n * ```\n */\n format(value: number | string, options?: CurrencyFormatOptions): string {\n options = {\n startingUnit: this.c.startingUnit,\n precision: this.c.precision,\n ignoreZeroPrecision: this.c.ignoreZeroPrecision,\n ngCurrency: this.c.ngCurrency,\n ...options\n };\n let truthValue = Number(value);\n if (value == null || isNaN(truthValue)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n truthValue = truthValue / 100;\n }\n if (options.ngCurrency != null) {\n const cur = options.ngCurrency!;\n return this.currencyPipe.transform(\n truthValue,\n cur.currencyCode,\n cur.display,\n cur.digitsInfo,\n cur.locale || this.locale\n )!;\n }\n const res = formatNumber(\n truthValue,\n this.locale,\n `.${options.ignoreZeroPrecision ? 1 : options.precision}-${options.precision}`\n );\n return options.ignoreZeroPrecision ? res.replace(/(?:\\.[0]+)$/g, '') : res;\n }\n\n /**\n * Large number format filter\n *\n * 大数据格式化\n * ```ts\n * 1000 => { value: '1', unit: 'K', unitI18n: '千' }\n * 12456 => { value: '12.46', unit: 'K', unitI18n: '千' }\n * ```\n */\n mega(value: number | string, options?: CurrencyMegaOptions): CurrencyMegaResult {\n options = { precision: this.c.precision, unitI18n: this.c.megaUnit, startingUnit: this.c.startingUnit, ...options };\n let num = Number(value);\n const res: CurrencyMegaResult = { raw: value, value: '', unit: '', unitI18n: '' };\n if (isNaN(num) || num === 0) {\n res.value = value.toString();\n return res;\n }\n if (options.startingUnit === 'cent') {\n num = num / 100;\n }\n let abs = Math.abs(+num);\n const rounder = Math.pow(10, options.precision!);\n const isNegative = num < 0;\n for (const p of CurrencyMega_Powers) {\n let reduced = abs / p.value;\n\n reduced = Math.round(reduced * rounder) / rounder;\n\n if (reduced >= 1) {\n abs = reduced;\n res.unit = p.unit;\n break;\n }\n }\n\n res.value = (isNegative ? '-' : '') + abs;\n res.unitI18n = (options.unitI18n as { [key: string]: NzSafeAny })[res.unit];\n return res;\n }\n\n /**\n * Converted into RMB notation.\n *\n * 转化成人民币表示法\n */\n cny(value: number | string, options?: CurrencyCNYOptions): string {\n options = {\n inWords: true,\n minusSymbol: '负',\n startingUnit: this.c.startingUnit,\n ...options\n };\n\n value = Number(value);\n if (isNaN(value)) {\n return '';\n }\n if (options.startingUnit === 'cent') {\n value = value / 100;\n }\n value = value.toString();\n let integer: number | string;\n let decimal: number | string | null;\n [integer, decimal] = value.split('.');\n let symbol = '';\n if (integer.startsWith('-')) {\n symbol = options.minusSymbol!;\n integer = integer.substring(1);\n }\n if (/^-?\\d+$/.test(value)) {\n decimal = null;\n }\n integer = (+integer).toString();\n const inWords = options.inWords;\n const unit: { [key: string]: string[] } = {\n num: inWords\n ? ['', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '点']\n : ['', '一', '二', '三', '四', '五', '六', '七', '八', '九', '点'],\n radice: inWords\n ? [\n '',\n '拾',\n '佰',\n '仟',\n '万',\n '拾',\n '佰',\n '仟',\n '亿',\n '拾',\n '佰',\n '仟',\n '万亿',\n '拾',\n '佰',\n '仟',\n '兆',\n '拾',\n '佰',\n '仟'\n ]\n : [\n '',\n '十',\n '百',\n '千',\n '万',\n '十',\n '百',\n '千',\n '亿',\n '十',\n '百',\n '千',\n '万亿',\n '十',\n '百',\n '千',\n '兆',\n '十',\n '百',\n '千'\n ],\n dec: ['角', '分', '厘', '毫']\n };\n if (inWords) {\n value = (+value).toFixed(5).toString();\n }\n let integerRes = '';\n const integerCount = integer.length;\n if (integer === '0' || integerCount === 0) {\n integerRes = '零';\n } else {\n let cnDesc = '';\n for (let i = 0; i < integerCount; i++) {\n const n = +integer[i];\n const j = integerCount - i - 1;\n const isZero = i > 1 && n !== 0 && integer[i - 1] === '0';\n const cnZero = isZero ? '零' : '';\n const isEmpptyUnit = (n === 0 && j % 4 !== 0) || integer.substring(i - 3, i - 3 + 4) === '0000';\n const descMark = cnDesc;\n let cnNum = unit.num[n];\n\n cnDesc = isEmpptyUnit ? '' : unit.radice[j];\n // 第一位是一十\n if (i === 0 && cnNum === '一' && cnDesc === '十') cnNum = '';\n const isChangeEr =\n n > 1 &&\n cnNum === '二' && // 去除首位\n ['', '十', '百'].indexOf(cnDesc) === -1 && // 不读两\\两十\\两百\n descMark !== '十'; // 不读十两\n if (isChangeEr) cnNum = '两';\n integerRes += cnZero + cnNum + cnDesc;\n }\n }\n\n // 小数部分拼接\n let decimalRes = '';\n const decimalCount = decimal ? decimal.toString().length : 0;\n if (decimal === null) {\n decimalRes = inWords ? '整' : '';\n } else if (decimal === '0') {\n decimalRes = '零';\n } else {\n for (let i = 0; i < decimalCount; i++) {\n if (inWords && i > unit.dec.length - 1) break;\n const n = decimal[i];\n const cnZero = n === '0' ? '零' : '';\n const cnNum = unit.num[+n];\n const cnDesc = inWords ? unit.dec[i] : '';\n decimalRes += cnZero + cnNum + cnDesc;\n }\n }\n const ret =\n symbol +\n (inWords\n ? integerRes + (decimalRes === '零' ? '元整' : `元${decimalRes}`)\n : integerRes + (decimalRes === '' ? '' : `点${decimalRes}`));\n return ret;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGA;;;;;;;;;;AAUG;AACG,SAAU,MAAM,CACpB,GAA8B,EAC9B,GAAiC,EACjC,cAAuB,KAAK,EAAA;IAE5B,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,KAAa,EAAE,GAAW,KACpE,WAAW,GAAG,OAAO,CA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,EAAA,IAAA,EAAA,eAAe,cADF,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,eAAe,EAAA,UAAA,EAAA,CAAA;kBAD3B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAO7B,MAAM;2BAAC,SAAS,CAAA;;0BAChB,MAAM;2BAAC,qBAAqB,CAAA;;;ACtBjC;;AAEG;;;;"}
@@ -1,85 +1,85 @@
1
- import { assertNumber } from '@yelon/util/other';
2
-
3
- /**
4
- * Checks if `value` is between `start` and `end` to, but not including `end`. If `end` is not specified, it's set to start with `start` then set to `0`. If `start` is greater than `end` the params are swapped to support negative ranges.
5
- *
6
- * 检查 `value` 是否在 `start` 与 `end` 之间,但不包括 `end`。 如果 `end` 没有指定,那么 `start` 设置为 `0`。 如果 `start` 大于 `end`,那么参数会交换以便支持负范围。
7
- * ```ts
8
- * inRange(3, 2, 4); // true
9
- * inRange(4, 8); // true
10
- * inRange(4, 2); // false
11
- * inRange(2, 2); // false
12
- * inRange(1.2, 2); // true
13
- * inRange(-3, -2, -6); // true
14
- * ```
15
- */
16
- function inRange(value, start, end) {
17
- if (end === undefined) {
18
- end = start;
19
- start = 0;
20
- }
21
- assertNumber(value);
22
- assertNumber(start);
23
- assertNumber(end);
24
- return value >= Math.min(start, end) && value < Math.max(start, end);
25
- }
26
-
27
- /**
28
- * Computes `number` rounded up to `precision`.
29
- *
30
- * 根据 `precision`(精度) 向上舍入 `number`。
31
- * ```ts
32
- * ceil(4.006); // 5
33
- * ceil(6.004, 2); // 6.01
34
- * ceil(6040, -2); // 6100
35
- * ```
36
- */
37
- function ceil(number, precision = 0) {
38
- return createRound(number, precision, 'ceil');
39
- }
40
- /**
41
- * Computes `number` rounded down to `precision`.
42
- *
43
- * 根据 `precision`(精度) 向下舍入 `number`。
44
- * ```ts
45
- * floor(4.006); // 4
46
- * floor(0.046, 2); // 0.04
47
- * floor(4060, -2); // 4000
48
- * ```
49
- */
50
- function floor(number, precision = 0) {
51
- return createRound(number, precision, 'floor');
52
- }
53
- /**
54
- * Computes `number` rounded to `precision`.
55
- *
56
- * 根据 `precision`(精度) 四舍五入 `number`。
57
- * ```ts
58
- * round(4.006); // 4
59
- * round(4.006, 2); // 4.01
60
- * round(4060, -2); // 4100
61
- * ```
62
- */
63
- function round(number, precision = 0) {
64
- return createRound(number, precision, 'round');
65
- }
66
- function createRound(number, precision, methodName) {
67
- const func = Math[methodName];
68
- precision = precision == null ? 0 : Math.min(precision, 292);
69
- if (!precision) {
70
- return func(number);
71
- }
72
- // Shift with exponential notation to avoid floating-point issues.
73
- // See [MDN](https://mdn.io/round#Examples) for more details.
74
- let pair = `${number}e`.split('e');
75
- const value = func(Number(`${pair[0]}e${Number(pair[1]) + precision}`));
76
- pair = `${value}e`.split('e');
77
- return Number(`${pair[0]}e${Number(pair[1]) - precision}`);
78
- }
79
-
80
- /**
81
- * Generated bundle index. Do not edit.
82
- */
83
-
84
- export { ceil, floor, inRange, round };
85
- //# sourceMappingURL=math.mjs.map
1
+ import { assertNumber } from '@yelon/util/other';
2
+
3
+ /**
4
+ * Checks if `value` is between `start` and `end` to, but not including `end`. If `end` is not specified, it's set to start with `start` then set to `0`. If `start` is greater than `end` the params are swapped to support negative ranges.
5
+ *
6
+ * 检查 `value` 是否在 `start` 与 `end` 之间,但不包括 `end`。 如果 `end` 没有指定,那么 `start` 设置为 `0`。 如果 `start` 大于 `end`,那么参数会交换以便支持负范围。
7
+ * ```ts
8
+ * inRange(3, 2, 4); // true
9
+ * inRange(4, 8); // true
10
+ * inRange(4, 2); // false
11
+ * inRange(2, 2); // false
12
+ * inRange(1.2, 2); // true
13
+ * inRange(-3, -2, -6); // true
14
+ * ```
15
+ */
16
+ function inRange(value, start, end) {
17
+ if (end === undefined) {
18
+ end = start;
19
+ start = 0;
20
+ }
21
+ assertNumber(value);
22
+ assertNumber(start);
23
+ assertNumber(end);
24
+ return value >= Math.min(start, end) && value < Math.max(start, end);
25
+ }
26
+
27
+ /**
28
+ * Computes `number` rounded up to `precision`.
29
+ *
30
+ * 根据 `precision`(精度) 向上舍入 `number`。
31
+ * ```ts
32
+ * ceil(4.006); // 5
33
+ * ceil(6.004, 2); // 6.01
34
+ * ceil(6040, -2); // 6100
35
+ * ```
36
+ */
37
+ function ceil(number, precision = 0) {
38
+ return createRound(number, precision, 'ceil');
39
+ }
40
+ /**
41
+ * Computes `number` rounded down to `precision`.
42
+ *
43
+ * 根据 `precision`(精度) 向下舍入 `number`。
44
+ * ```ts
45
+ * floor(4.006); // 4
46
+ * floor(0.046, 2); // 0.04
47
+ * floor(4060, -2); // 4000
48
+ * ```
49
+ */
50
+ function floor(number, precision = 0) {
51
+ return createRound(number, precision, 'floor');
52
+ }
53
+ /**
54
+ * Computes `number` rounded to `precision`.
55
+ *
56
+ * 根据 `precision`(精度) 四舍五入 `number`。
57
+ * ```ts
58
+ * round(4.006); // 4
59
+ * round(4.006, 2); // 4.01
60
+ * round(4060, -2); // 4100
61
+ * ```
62
+ */
63
+ function round(number, precision = 0) {
64
+ return createRound(number, precision, 'round');
65
+ }
66
+ function createRound(number, precision, methodName) {
67
+ const func = Math[methodName];
68
+ precision = precision == null ? 0 : Math.min(precision, 292);
69
+ if (!precision) {
70
+ return func(number);
71
+ }
72
+ // Shift with exponential notation to avoid floating-point issues.
73
+ // See [MDN](https://mdn.io/round#Examples) for more details.
74
+ let pair = `${number}e`.split('e');
75
+ const value = func(Number(`${pair[0]}e${Number(pair[1]) + precision}`));
76
+ pair = `${value}e`.split('e');
77
+ return Number(`${pair[0]}e${Number(pair[1]) - precision}`);
78
+ }
79
+
80
+ /**
81
+ * Generated bundle index. Do not edit.
82
+ */
83
+
84
+ export { ceil, floor, inRange, round };
85
+ //# sourceMappingURL=math.mjs.map