@tmlmobilidade/utils 20250730.2337.59 → 20250730.2353.33
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/dist/src/files/files.d.ts +7 -1
- package/dist/src/files/files.js +14 -6
- package/package.json +2 -2
|
@@ -12,7 +12,13 @@ export declare class Files {
|
|
|
12
12
|
*/
|
|
13
13
|
static blobToFile(blob: Blob, fileName: string): File;
|
|
14
14
|
static getFileExtension(fileName: string): string;
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Gets the file extension from a MIME type.
|
|
17
|
+
* @param mimeType The MIME type to get the file extension for.
|
|
18
|
+
* @returns The file extension, or an empty string if not found.
|
|
19
|
+
*/
|
|
20
|
+
static getFileExtensionFromMimeType(mimeType: string): string;
|
|
21
|
+
static getMimeTypeFromFileExtension(fileName: string): string;
|
|
16
22
|
/**
|
|
17
23
|
* Parses a CSV string into an array of objects using PapaParse.
|
|
18
24
|
* @param csvString - The CSV string to parse
|
package/dist/src/files/files.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
|
2
1
|
/* * */
|
|
3
2
|
import { mimeTypes } from '@tmlmobilidade/lib';
|
|
4
3
|
import JSZip from 'jszip';
|
|
@@ -7,10 +6,6 @@ import { fetchZipFromUrl, isBrowser, normalizeFileContent, readZipFromFile } fro
|
|
|
7
6
|
/* * */
|
|
8
7
|
export class Files {
|
|
9
8
|
//
|
|
10
|
-
//
|
|
11
|
-
// Static properties
|
|
12
|
-
//
|
|
13
|
-
// Static methods
|
|
14
9
|
/**
|
|
15
10
|
* Blob to JS File
|
|
16
11
|
*/
|
|
@@ -28,7 +23,20 @@ export class Files {
|
|
|
28
23
|
}
|
|
29
24
|
return extension;
|
|
30
25
|
}
|
|
31
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Gets the file extension from a MIME type.
|
|
28
|
+
* @param mimeType The MIME type to get the file extension for.
|
|
29
|
+
* @returns The file extension, or an empty string if not found.
|
|
30
|
+
*/
|
|
31
|
+
static getFileExtensionFromMimeType(mimeType) {
|
|
32
|
+
if (!mimeType)
|
|
33
|
+
return '';
|
|
34
|
+
const extension = Object.keys(mimeTypes).find(key => mimeTypes[key] === mimeType);
|
|
35
|
+
if (!extension)
|
|
36
|
+
return '';
|
|
37
|
+
return extension;
|
|
38
|
+
}
|
|
39
|
+
static getMimeTypeFromFileExtension(fileName) {
|
|
32
40
|
const extension = Files.getFileExtension(fileName);
|
|
33
41
|
return mimeTypes[extension];
|
|
34
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmlmobilidade/utils",
|
|
3
|
-
"version": "20250730.
|
|
3
|
+
"version": "20250730.2353.33",
|
|
4
4
|
"author": "João de Vasconcelos & Jusi Monteiro",
|
|
5
5
|
"license": "AGPL-3.0-or-later",
|
|
6
6
|
"homepage": "https://github.com/tmlmobilidade/services#readme",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@carrismetropolitana/eslint": "20250622.1204.50",
|
|
54
54
|
"@tmlmobilidade/tsconfig": "*",
|
|
55
55
|
"@tmlmobilidade/types": "*",
|
|
56
|
-
"@types/luxon": "3.
|
|
56
|
+
"@types/luxon": "3.7.1",
|
|
57
57
|
"@types/node": "24.1.0",
|
|
58
58
|
"@types/papaparse": "5.3.16",
|
|
59
59
|
"resolve-tspaths": "0.8.23",
|