hsu-utils 0.0.33 → 0.0.35
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.
- package/README.md +3 -3
- package/dist/hsu-utils.js +3 -3
- package/dist/hsu-utils.min.js +1 -1
- package/dist/hsu-utils.min.js.LICENSE.txt +1 -1
- package/es/ConvertNumbers/index.js +1 -1
- package/es/DownloadFile/index.d.ts +1 -1
- package/es/DownloadFile/index.js +14 -7
- package/lib/ConvertNumbers/index.js +1 -1
- package/lib/DownloadFile/index.d.ts +1 -1
- package/lib/DownloadFile/index.js +14 -7
- package/package.json +1 -1
package/README.md
CHANGED
@@ -20,7 +20,7 @@ yarn add hsu-utils
|
|
20
20
|
| console_table | - | 在控制台打印像 MySql 一样的表格 | (data: [ConsoleData](#consoledata), callBack?: (str: string) => void) => void | - |
|
21
21
|
| ConvertNumbers | toChineseNum | 数字转中文 | (num: number, options?: [C_Options](#c_options)) => string | - |
|
22
22
|
| deepCopy | - | 深拷贝 | \<T>(data: T) => T | - |
|
23
|
-
| downloadFile | - | 文件下载 | (file: ArrayBuffer \| string, fileName
|
23
|
+
| downloadFile | - | 文件下载 | (file: ArrayBuffer \| string, fileName?: string) => void | string 为 http(s) 地址或本地地址 |
|
24
24
|
| Equal | ValEqual | 判断值相等 | <T = unknown>(obj1: T, obj2: T) => boolean | - |
|
25
25
|
| | TypeEqual | 判断类型相同 | <T = unknown>(obj1: T, obj2: T) => boolean | - |
|
26
26
|
| | ObjEqual | 判断对象相等 | <T = object>(obj1: T, obj2: T) => boolean | - |
|
@@ -49,8 +49,8 @@ yarn add hsu-utils
|
|
49
49
|
|
50
50
|
> type TextType = 'lowercase' | 'uppercase'
|
51
51
|
|
52
|
-
`lowercase` ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
|
53
|
-
`uppercase` ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
|
52
|
+
`lowercase` ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '百', '千', '万', '亿', '兆']
|
53
|
+
`uppercase` ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾', '佰', '仟', '萬', '億', '兆']
|
54
54
|
|
55
55
|
### Font
|
56
56
|
|
package/dist/hsu-utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* hsu-utils v0.0.
|
3
|
+
* hsu-utils v0.0.34
|
4
4
|
*
|
5
5
|
* some front-end utils
|
6
6
|
*
|
@@ -87,7 +87,7 @@ eval("\nvar __values = (this && this.__values) || function(o) {\n var s = typ
|
|
87
87
|
/***/ ((__unused_webpack_module, exports) => {
|
88
88
|
|
89
89
|
"use strict";
|
90
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.toChineseNum = void 0;\nfunction toChineseNum(num, options) {\n if (options === void 0) { options = {}; }\n var benchmark = options.benchmark, _a = options.textType, textType = _a === void 0 ? 'lowercase' : _a;\n var cnNums = {\n lowercase: ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'],\n uppercase: ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']\n };\n var cnIntRadice = {\n lowercase: ['', '十', '百', '千'],\n uppercase: ['', '拾', '佰', '仟']\n };\n var cnIntUnits = {\n lowercase: ['', '万', '亿', '兆'],\n uppercase: ['', '
|
90
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.toChineseNum = void 0;\nfunction toChineseNum(num, options) {\n if (options === void 0) { options = {}; }\n var benchmark = options.benchmark, _a = options.textType, textType = _a === void 0 ? 'lowercase' : _a;\n var cnNums = {\n lowercase: ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'],\n uppercase: ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']\n };\n var cnIntRadice = {\n lowercase: ['', '十', '百', '千'],\n uppercase: ['', '拾', '佰', '仟']\n };\n var cnIntUnits = {\n lowercase: ['', '万', '亿', '兆'],\n uppercase: ['', '萬', '億', '兆']\n };\n var maxNum = 9999999999999999.9999999999999999;\n var integerNum = undefined;\n var decimalNum = undefined;\n var chineseStr = '';\n if (benchmark) {\n num *= benchmark;\n }\n if (num > maxNum) {\n return '超出转换范围';\n }\n var moneyStr = num.toString();\n integerNum = moneyStr.split('.')[0];\n decimalNum = moneyStr.split('.')[1];\n if (integerNum) {\n var zeroCount = 0;\n for (var i = 0; i < integerNum.length; i++) {\n var index = integerNum.length - i - 1;\n var num_1 = +integerNum[i];\n var units = Math.floor(index / 4);\n var radice = index % (4 * (units === 0 ? 1 : units));\n if (+integerNum[i] === 0) {\n zeroCount++;\n }\n else {\n if (zeroCount > 0) {\n chineseStr += cnNums[textType][0];\n zeroCount = 0;\n }\n chineseStr += \"\".concat(cnNums[textType][num_1] + cnIntRadice[textType][radice]);\n if (index % 4 === 0) {\n chineseStr += cnIntUnits[textType][units];\n }\n }\n }\n }\n if (decimalNum) {\n chineseStr += '点';\n for (var i = 0; i < decimalNum.length; i++) {\n var num_2 = +decimalNum[i];\n if (+decimalNum[i] === 0) {\n chineseStr += \"\".concat(cnNums[textType][0]);\n }\n else {\n chineseStr += \"\".concat(cnNums[textType][num_2]);\n }\n }\n }\n if (chineseStr === '') {\n chineseStr += cnNums[textType][0];\n }\n return chineseStr;\n}\nexports.toChineseNum = toChineseNum;\nvar ConvertNumbers = {\n toChineseNum: toChineseNum\n};\nexports[\"default\"] = ConvertNumbers;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/ConvertNumbers/index.ts?");
|
91
91
|
|
92
92
|
/***/ }),
|
93
93
|
|
@@ -109,7 +109,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
|
|
109
109
|
/***/ ((__unused_webpack_module, exports) => {
|
110
110
|
|
111
111
|
"use strict";
|
112
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunction downloadFileByLocalPath(path, fileName) {\n fetch(path)\n .then(function (response) { return response.arrayBuffer(); })\n .then(function (arrayBuffer) {\n downloadFile(arrayBuffer, fileName);\n });\n}\nfunction downloadFileByUrl(url, fileName) {\n if (!url.startsWith('http')) {\n downloadFileByLocalPath(url, fileName);\n return;\n }\n var downloadElement = document.createElement('a');\n
|
112
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunction downloadFileByLocalPath(path, fileName) {\n fetch(path)\n .then(function (response) { return response.arrayBuffer(); })\n .then(function (arrayBuffer) {\n downloadFile(arrayBuffer, fileName);\n });\n}\nfunction downloadFileByUrl(url, fileName) {\n if (!url.startsWith('http')) {\n downloadFileByLocalPath(url, fileName);\n return;\n }\n fetch(url)\n .then(function (response) { return response.arrayBuffer(); })\n .then(function (arrayBuffer) {\n downloadFile(arrayBuffer, fileName);\n })\n .catch(function () {\n var downloadElement = document.createElement('a');\n downloadElement.href = url;\n downloadElement.download = decodeURIComponent(fileName || '');\n document.body.appendChild(downloadElement);\n downloadElement.click();\n document.body.removeChild(downloadElement);\n });\n}\nfunction downloadFile(file, fileName) {\n if (typeof file === 'string') {\n downloadFileByUrl(file, fileName);\n return;\n }\n var blob = new Blob([file]);\n var downloadElement = document.createElement('a');\n var href = window.URL.createObjectURL(blob);\n downloadElement.href = href;\n downloadElement.download = decodeURIComponent(fileName || '');\n document.body.appendChild(downloadElement);\n downloadElement.click();\n document.body.removeChild(downloadElement);\n window.URL.revokeObjectURL(href);\n}\nexports[\"default\"] = downloadFile;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/DownloadFile/index.ts?");
|
113
113
|
|
114
114
|
/***/ }),
|
115
115
|
|