hsu-utils 0.0.53 → 0.0.55
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 +35 -11
- package/dist/hsu-utils.js +14 -4
- package/dist/hsu-utils.min.js +1 -1
- package/dist/hsu-utils.min.js.LICENSE.txt +2 -2
- package/es/DownloadFile/index.d.ts +7 -1
- package/es/DownloadFile/index.js +8 -1
- package/es/GetDateRange/index.js +2 -0
- package/lib/DownloadFile/index.d.ts +7 -1
- package/lib/DownloadFile/index.js +8 -1
- package/lib/GetDateRange/index.js +2 -0
- package/package.json +16 -3
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type ResponseLike = Response | {
|
|
2
|
+
headers: Record<string, string> | {
|
|
3
|
+
get(name: string): string | null;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
export declare function getFileNameFromHeader(response: ResponseLike): string | null;
|
|
2
7
|
export default function downloadFile(file: ArrayBuffer | Blob | string, fileName?: string, signal?: AbortSignal): Promise<void>;
|
|
8
|
+
export {};
|
package/es/DownloadFile/index.js
CHANGED
|
@@ -9,7 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Typeof } from '..';
|
|
11
11
|
export function getFileNameFromHeader(response) {
|
|
12
|
-
|
|
12
|
+
let contentDisposition = null;
|
|
13
|
+
if (response.headers && typeof response.headers.get === 'function') {
|
|
14
|
+
contentDisposition = response.headers.get('Content-Disposition');
|
|
15
|
+
}
|
|
16
|
+
else if (response.headers && typeof response.headers === 'object') {
|
|
17
|
+
const headers = response.headers;
|
|
18
|
+
contentDisposition = headers['content-disposition'] || headers['Content-Disposition'] || null;
|
|
19
|
+
}
|
|
13
20
|
if (!contentDisposition) {
|
|
14
21
|
return null;
|
|
15
22
|
}
|
package/es/GetDateRange/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
3
3
|
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
4
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
4
5
|
dayjs.extend(quarterOfYear);
|
|
5
6
|
dayjs.extend(weekOfYear);
|
|
7
|
+
dayjs.extend(advancedFormat);
|
|
6
8
|
function getFormat(type, unit = 'day', hasTime = false) {
|
|
7
9
|
let baseFormat;
|
|
8
10
|
switch (type) {
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type ResponseLike = Response | {
|
|
2
|
+
headers: Record<string, string> | {
|
|
3
|
+
get(name: string): string | null;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
export declare function getFileNameFromHeader(response: ResponseLike): string | null;
|
|
2
7
|
export default function downloadFile(file: ArrayBuffer | Blob | string, fileName?: string, signal?: AbortSignal): Promise<void>;
|
|
8
|
+
export {};
|
|
@@ -39,7 +39,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.getFileNameFromHeader = void 0;
|
|
40
40
|
var __1 = require("..");
|
|
41
41
|
function getFileNameFromHeader(response) {
|
|
42
|
-
var contentDisposition =
|
|
42
|
+
var contentDisposition = null;
|
|
43
|
+
if (response.headers && typeof response.headers.get === 'function') {
|
|
44
|
+
contentDisposition = response.headers.get('Content-Disposition');
|
|
45
|
+
}
|
|
46
|
+
else if (response.headers && typeof response.headers === 'object') {
|
|
47
|
+
var headers = response.headers;
|
|
48
|
+
contentDisposition = headers['content-disposition'] || headers['Content-Disposition'] || null;
|
|
49
|
+
}
|
|
43
50
|
if (!contentDisposition) {
|
|
44
51
|
return null;
|
|
45
52
|
}
|
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
var dayjs_1 = __importDefault(require("dayjs"));
|
|
7
7
|
var quarterOfYear_1 = __importDefault(require("dayjs/plugin/quarterOfYear"));
|
|
8
8
|
var weekOfYear_1 = __importDefault(require("dayjs/plugin/weekOfYear"));
|
|
9
|
+
var advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
|
|
9
10
|
dayjs_1.default.extend(quarterOfYear_1.default);
|
|
10
11
|
dayjs_1.default.extend(weekOfYear_1.default);
|
|
12
|
+
dayjs_1.default.extend(advancedFormat_1.default);
|
|
11
13
|
function getFormat(type, unit, hasTime) {
|
|
12
14
|
if (unit === void 0) { unit = 'day'; }
|
|
13
15
|
if (hasTime === void 0) { hasTime = false; }
|
package/package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hsu-utils",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.55",
|
|
4
|
+
"description": "常用前端工具集:深拷贝、类型判断、相等比较、文件下载、PDF 渲染、日期范围、控制台表格等",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"utils",
|
|
7
|
+
"frontend",
|
|
8
|
+
"deep-copy",
|
|
9
|
+
"download",
|
|
10
|
+
"pdf",
|
|
11
|
+
"date-range",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/VitaTsui/hsu-utils#readme",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/VitaTsui/hsu-utils.git"
|
|
18
|
+
},
|
|
6
19
|
"author": "VitaHsu <vitahsu7@gmail.com>",
|
|
7
20
|
"license": "MIT",
|
|
8
21
|
"main": "lib/index.js",
|