uti 8.3.0 → 8.3.2
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 +14 -3
- package/package.json +3 -3
- package/src/uti.mjs +6 -6
- package/{dist → types}/uti.d.mts +7 -7
- /package/{dist → types}/well-known-utis.d.mts +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/uti)
|
|
2
2
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
3
|
+
[](https://typescriptlang.org)
|
|
3
4
|
[](https://bundlejs.com/?q=uti)
|
|
4
5
|
[](https://npmjs.org/package/uti)
|
|
5
6
|
[](https://github.com/arlac77/uti/issues)
|
|
@@ -54,6 +55,8 @@ public.plain-text
|
|
|
54
55
|
* [toJSON](#tojson)
|
|
55
56
|
* [UTIController](#uticontroller)
|
|
56
57
|
* [Properties](#properties-1)
|
|
58
|
+
* [utiByMimeType](#utibymimetype)
|
|
59
|
+
* [utiByFileNameExtension](#utibyfilenameextension)
|
|
57
60
|
* [register](#register)
|
|
58
61
|
* [Parameters](#parameters-2)
|
|
59
62
|
* [getUTI](#getuti)
|
|
@@ -115,6 +118,14 @@ Registry of UTIs.
|
|
|
115
118
|
* `utiByMimeType` **[Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [UTI](#uti)>** 
|
|
116
119
|
* `utiByFileNameExtension` **[Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [UTI](#uti)>** 
|
|
117
120
|
|
|
121
|
+
### utiByMimeType
|
|
122
|
+
|
|
123
|
+
Type: [Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>>
|
|
124
|
+
|
|
125
|
+
### utiByFileNameExtension
|
|
126
|
+
|
|
127
|
+
Type: [Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>>
|
|
128
|
+
|
|
118
129
|
### register
|
|
119
130
|
|
|
120
131
|
Registers additional types.
|
|
@@ -131,7 +142,7 @@ Lookup a given UTI.
|
|
|
131
142
|
|
|
132
143
|
* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** UTI
|
|
133
144
|
|
|
134
|
-
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** UTI for the given name or undefined if UTI is not present.
|
|
145
|
+
Returns **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** UTI for the given name or undefined if UTI is not present.
|
|
135
146
|
|
|
136
147
|
### getUTIsForMimeType
|
|
137
148
|
|
|
@@ -141,7 +152,7 @@ Lookup a UTIs for a mime type.
|
|
|
141
152
|
|
|
142
153
|
* `mimeType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** mime type to get UTIs for
|
|
143
154
|
|
|
144
|
-
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
155
|
+
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** UTIs for the given mime type
|
|
145
156
|
|
|
146
157
|
### getUTIsForFileName
|
|
147
158
|
|
|
@@ -153,7 +164,7 @@ Then a lookup in the reistered UTIs for file name extions is executed.
|
|
|
153
164
|
|
|
154
165
|
* `fileName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file to detect UTI for
|
|
155
166
|
|
|
156
|
-
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**
|
|
167
|
+
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** UTIs for the given fileName
|
|
157
168
|
|
|
158
169
|
### conformsTo
|
|
159
170
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uti",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "BSD-2-Clause",
|
|
27
27
|
"scripts": {
|
|
28
|
-
"prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir
|
|
28
|
+
"prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
|
|
29
29
|
"test": "npm run test:browser-ava && npm run test:ava",
|
|
30
30
|
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
31
31
|
"test:browser-ava": "browser-ava --headless --no-keep-open tests/*-ava.mjs tests/*-ava-browser.mjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"ava": "^6.1.1",
|
|
40
|
-
"browser-ava": "^2.
|
|
40
|
+
"browser-ava": "^2.2.0",
|
|
41
41
|
"c8": "^9.1.0",
|
|
42
42
|
"documentation": "^14.0.3",
|
|
43
43
|
"semantic-release": "^23.0.2",
|
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]+)$/);
|
package/{dist → types}/uti.d.mts
RENAMED
|
@@ -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
|
/**
|
|
File without changes
|