hsu-utils 0.0.37 → 0.0.39
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 +1 -1
- package/dist/hsu-utils.js +2 -2
- package/dist/hsu-utils.min.js +1 -1
- package/dist/hsu-utils.min.js.LICENSE.txt +1 -1
- package/es/DownloadFile/index.d.ts +1 -1
- package/es/DownloadFile/index.js +13 -11
- package/lib/DownloadFile/index.d.ts +1 -1
- package/lib/DownloadFile/index.js +19 -17
- 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?: string) => void
|
23
|
+
| downloadFile | - | 文件下载 | (file: ArrayBuffer \| string, fileName?: string, signal?: AbortSignal) => 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 | - |
|
package/dist/hsu-utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* hsu-utils v0.0.
|
3
|
+
* hsu-utils v0.0.38
|
4
4
|
*
|
5
5
|
* some front-end utils
|
6
6
|
*
|
@@ -109,7 +109,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar
|
|
109
109
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
110
110
|
|
111
111
|
"use strict";
|
112
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar __1 = __webpack_require__(/*! .. */ \"./tools/index.ts\");\nfunction downloadFileByUrl(url, fileName) {\n return __awaiter(this, void 0, void 0, function () {\n var response, arrayBuffer,
|
112
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar __1 = __webpack_require__(/*! .. */ \"./tools/index.ts\");\nfunction downloadFileByUrl(url, fileName, signal) {\n return __awaiter(this, void 0, void 0, function () {\n var response, arrayBuffer, error_1, downloadElement;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n return [4, fetch(url, { signal: signal })];\n case 1:\n response = _a.sent();\n return [4, response.arrayBuffer()];\n case 2:\n arrayBuffer = _a.sent();\n downloadFile(arrayBuffer, fileName);\n return [3, 4];\n case 3:\n error_1 = _a.sent();\n if ((error_1 === null || error_1 === void 0 ? void 0 : error_1.name) !== 'AbortError') {\n 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 return [3, 4];\n case 4: return [2];\n }\n });\n });\n}\nfunction downloadFile(file, fileName, signal) {\n return __awaiter(this, void 0, void 0, function () {\n var blob, downloadElement, href;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(typeof file === 'string')) return [3, 2];\n return [4, downloadFileByUrl(file, fileName, signal)];\n case 1:\n _a.sent();\n return [3, 3];\n case 2:\n blob = (0, __1.Typeof)(file) === 'blob' ? file : new Blob([file]);\n downloadElement = document.createElement('a');\n 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 _a.label = 3;\n case 3: return [2];\n }\n });\n });\n}\nexports[\"default\"] = downloadFile;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/DownloadFile/index.ts?");
|
113
113
|
|
114
114
|
/***/ }),
|
115
115
|
|