uti 8.3.0 → 8.3.1
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/uti.d.mts +7 -7
- package/package.json +1 -1
- package/src/uti.mjs +6 -6
package/dist/uti.d.mts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export class UTIController {
|
|
8
8
|
registry: Map<any, any>;
|
|
9
|
-
utiByMimeType: Map<
|
|
10
|
-
utiByFileNameExtension: Map<
|
|
9
|
+
/** @type {Map<string,string[]>} */ utiByMimeType: Map<string, string[]>;
|
|
10
|
+
/** @type {Map<string,string[]>} */ utiByFileNameExtension: Map<string, string[]>;
|
|
11
11
|
/**
|
|
12
12
|
* Registers additional types.
|
|
13
13
|
* @param {Object[]} types
|
|
@@ -16,21 +16,21 @@ export class UTIController {
|
|
|
16
16
|
/**
|
|
17
17
|
* Lookup a given UTI.
|
|
18
18
|
* @param {string} name UTI
|
|
19
|
-
* @return {string} UTI for the given name or undefined if UTI is not present.
|
|
19
|
+
* @return {string|undefined} UTI for the given name or undefined if UTI is not present.
|
|
20
20
|
*/
|
|
21
|
-
getUTI(name: string): string;
|
|
21
|
+
getUTI(name: string): string | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* Lookup a UTIs for a mime type.
|
|
24
24
|
* @param {string} mimeType mime type to get UTIs for
|
|
25
|
-
* @return {string}
|
|
25
|
+
* @return {string[]} UTIs for the given mime type
|
|
26
26
|
*/
|
|
27
|
-
getUTIsForMimeType(mimeType: string): string;
|
|
27
|
+
getUTIsForMimeType(mimeType: string): string[];
|
|
28
28
|
/**
|
|
29
29
|
* Lookup a UTI for a file name.
|
|
30
30
|
* First the file name extension is extracted.
|
|
31
31
|
* Then a lookup in the reistered UTIs for file name extions is executed.
|
|
32
32
|
* @param {string} fileName file to detect UTI for
|
|
33
|
-
* @return {string[]}
|
|
33
|
+
* @return {string[]} UTIs for the given fileName
|
|
34
34
|
*/
|
|
35
35
|
getUTIsForFileName(fileName: string): string[];
|
|
36
36
|
/**
|
package/package.json
CHANGED
package/src/uti.mjs
CHANGED
|
@@ -63,8 +63,8 @@ class UTI {
|
|
|
63
63
|
*/
|
|
64
64
|
export class UTIController {
|
|
65
65
|
registry = new Map();
|
|
66
|
-
utiByMimeType = new Map();
|
|
67
|
-
utiByFileNameExtension = new Map();
|
|
66
|
+
/** @type {Map<string,string[]>} */ utiByMimeType = new Map();
|
|
67
|
+
/** @type {Map<string,string[]>} */ utiByFileNameExtension = new Map();
|
|
68
68
|
|
|
69
69
|
constructor() {
|
|
70
70
|
this.register(types);
|
|
@@ -116,7 +116,7 @@ export class UTIController {
|
|
|
116
116
|
/**
|
|
117
117
|
* Lookup a given UTI.
|
|
118
118
|
* @param {string} name UTI
|
|
119
|
-
* @return {string} UTI for the given name or undefined if UTI is not present.
|
|
119
|
+
* @return {string|undefined} UTI for the given name or undefined if UTI is not present.
|
|
120
120
|
*/
|
|
121
121
|
getUTI(name) {
|
|
122
122
|
return this.registry.get(name);
|
|
@@ -125,10 +125,10 @@ export class UTIController {
|
|
|
125
125
|
/**
|
|
126
126
|
* Lookup a UTIs for a mime type.
|
|
127
127
|
* @param {string} mimeType mime type to get UTIs for
|
|
128
|
-
* @return {string}
|
|
128
|
+
* @return {string[]} UTIs for the given mime type
|
|
129
129
|
*/
|
|
130
130
|
getUTIsForMimeType(mimeType) {
|
|
131
|
-
return this.utiByMimeType.get(mimeType);
|
|
131
|
+
return this.utiByMimeType.get(mimeType) || [];
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
@@ -136,7 +136,7 @@ export class UTIController {
|
|
|
136
136
|
* First the file name extension is extracted.
|
|
137
137
|
* Then a lookup in the reistered UTIs for file name extions is executed.
|
|
138
138
|
* @param {string} fileName file to detect UTI for
|
|
139
|
-
* @return {string[]}
|
|
139
|
+
* @return {string[]} UTIs for the given fileName
|
|
140
140
|
*/
|
|
141
141
|
getUTIsForFileName(fileName) {
|
|
142
142
|
const m = fileName.match(/(\.[\.a-zA-Z_0-9]+)$/);
|