hsu-utils 0.0.38 → 0.0.40

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * hsu-utils v0.0.37
3
+ * hsu-utils v0.0.39
4
4
  *
5
5
  * some front-end utils
6
6
  *
@@ -15,14 +15,17 @@ function downloadFileByUrl(url, fileName, signal) {
15
15
  const arrayBuffer = yield response.arrayBuffer();
16
16
  downloadFile(arrayBuffer, fileName);
17
17
  }
18
- catch (_a) {
19
- const downloadElement = document.createElement('a');
20
- downloadElement.href = url;
21
- downloadElement.download = decodeURIComponent(fileName || '');
22
- document.body.appendChild(downloadElement);
23
- downloadElement.click();
24
- document.body.removeChild(downloadElement);
18
+ catch (error) {
19
+ if ((error === null || error === void 0 ? void 0 : error.name) !== 'AbortError') {
20
+ const downloadElement = document.createElement('a');
21
+ downloadElement.href = url;
22
+ downloadElement.download = decodeURIComponent(fileName || '');
23
+ document.body.appendChild(downloadElement);
24
+ downloadElement.click();
25
+ document.body.removeChild(downloadElement);
26
+ }
25
27
  }
28
+ return;
26
29
  });
27
30
  }
28
31
  export default function downloadFile(file, fileName, signal) {
@@ -41,5 +44,6 @@ export default function downloadFile(file, fileName, signal) {
41
44
  document.body.removeChild(downloadElement);
42
45
  window.URL.revokeObjectURL(href);
43
46
  }
47
+ return;
44
48
  });
45
49
  }
@@ -39,27 +39,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var __1 = require("..");
40
40
  function downloadFileByUrl(url, fileName, signal) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
- var response, arrayBuffer, _a, downloadElement;
43
- return __generator(this, function (_b) {
44
- switch (_b.label) {
42
+ var response, arrayBuffer, error_1, downloadElement;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
45
  case 0:
46
- _b.trys.push([0, 3, , 4]);
46
+ _a.trys.push([0, 3, , 4]);
47
47
  return [4, fetch(url, { signal: signal })];
48
48
  case 1:
49
- response = _b.sent();
49
+ response = _a.sent();
50
50
  return [4, response.arrayBuffer()];
51
51
  case 2:
52
- arrayBuffer = _b.sent();
52
+ arrayBuffer = _a.sent();
53
53
  downloadFile(arrayBuffer, fileName);
54
54
  return [3, 4];
55
55
  case 3:
56
- _a = _b.sent();
57
- downloadElement = document.createElement('a');
58
- downloadElement.href = url;
59
- downloadElement.download = decodeURIComponent(fileName || '');
60
- document.body.appendChild(downloadElement);
61
- downloadElement.click();
62
- document.body.removeChild(downloadElement);
56
+ error_1 = _a.sent();
57
+ if ((error_1 === null || error_1 === void 0 ? void 0 : error_1.name) !== 'AbortError') {
58
+ downloadElement = document.createElement('a');
59
+ downloadElement.href = url;
60
+ downloadElement.download = decodeURIComponent(fileName || '');
61
+ document.body.appendChild(downloadElement);
62
+ downloadElement.click();
63
+ document.body.removeChild(downloadElement);
64
+ }
63
65
  return [3, 4];
64
66
  case 4: return [2];
65
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hsu-utils",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "some front-end utils",
5
5
  "repository": "git@github.com:VitaTsui/hsu-utils.git",
6
6
  "author": "VitaHsu <vitahsu7@gmail.com>",