uti 8.4.0 → 8.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uti",
3
- "version": "8.4.0",
3
+ "version": "8.4.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -26,23 +26,24 @@
26
26
  ],
27
27
  "license": "BSD-2-Clause",
28
28
  "scripts": {
29
- "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
29
+ "prepare": "npm run prepare:typescript",
30
+ "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
30
31
  "test": "npm run test:browser-ava && npm run test:ava",
31
32
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
32
33
  "test:browser-ava": "browser-ava --headless --no-keep-open tests/*-ava.mjs tests/*-ava-browser.mjs",
33
34
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
34
35
  "docs": "documentation readme --section=API ./src/**/*.mjs",
35
- "lint": "npm run lint:docs && npm run lint:tsc",
36
+ "lint": "npm run lint:docs && npm run lint:typescript",
36
37
  "lint:docs": "documentation lint ./src/**/*.mjs",
37
- "lint:tsc": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
38
+ "lint:typescript": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
38
39
  },
39
40
  "devDependencies": {
40
- "ava": "^6.1.1",
41
- "browser-ava": "^2.2.0",
41
+ "ava": "^6.1.2",
42
+ "browser-ava": "^2.2.2",
42
43
  "c8": "^9.1.0",
43
44
  "documentation": "^14.0.3",
44
45
  "semantic-release": "^23.0.2",
45
- "typescript": "^5.3.3"
46
+ "typescript": "^5.4.2"
46
47
  },
47
48
  "engines": {
48
49
  "node": ">=20.11.1",
package/src/uti.mjs CHANGED
@@ -9,6 +9,14 @@ import types from "./well-known-utis.mjs";
9
9
  * @property {Set<UTI>} conforms
10
10
  */
11
11
  class UTI {
12
+ /**
13
+ * Object representing a UTI.
14
+ * @param {string} name
15
+ * @param {Set<UTI>} conforms
16
+ *
17
+ * @property {string} name
18
+ * @property {Set<UTI>} conforms
19
+ */
12
20
  constructor(name, conforms) {
13
21
  this.name = name;
14
22
  this.conforms = conforms;
@@ -32,6 +40,10 @@ class UTI {
32
40
  return false;
33
41
  }
34
42
 
43
+ /**
44
+ * name of the UTI.
45
+ * @returns {string}
46
+ */
35
47
  toString() {
36
48
  return this.name;
37
49
  }
@@ -45,7 +57,7 @@ class UTI {
45
57
  * "conformsTo": [ "uti1", "uti2"]
46
58
  * }
47
59
  * ```
48
- * @return {Object} json representation of the UTI
60
+ * @return {{name:string, conforms: string[]}} json representation of the UTI
49
61
  */
50
62
  toJSON() {
51
63
  return {
@@ -62,7 +74,7 @@ class UTI {
62
74
  * @property {Map<string,UTI>} utiByFileNameExtension
63
75
  */
64
76
  export class UTIController {
65
- registry = new Map();
77
+ /** @type {Map<string,UTI>} */ registry = new Map();
66
78
  /** @type {Map<string,string[]>} */ utiByMimeType = new Map();
67
79
  /** @type {Map<string,string[]>} */ utiByFileNameExtension = new Map();
68
80
 
@@ -116,7 +128,7 @@ export class UTIController {
116
128
  /**
117
129
  * Lookup a given UTI.
118
130
  * @param {string} name UTI
119
- * @return {string|undefined} UTI for the given name or undefined if UTI is not present.
131
+ * @return {UTI|undefined} UTI for the given name or undefined if UTI is not present.
120
132
  */
121
133
  getUTI(name) {
122
134
  return this.registry.get(name);
@@ -187,24 +199,34 @@ export class UTIController {
187
199
  return false;
188
200
  }
189
201
 
190
- assignMimeTypes(name, mimTypes) {
191
- mimTypes.forEach(type => {
202
+ /**
203
+ * Assign mime types to a UTI
204
+ * @param {string} uti
205
+ * @param {string[]} mimeTypes
206
+ */
207
+ assignMimeTypes(uti, mimeTypes) {
208
+ mimeTypes.forEach(type => {
192
209
  const u = this.utiByMimeType.get(type);
193
210
  if (u === undefined) {
194
- this.utiByMimeType.set(type, [name]);
211
+ this.utiByMimeType.set(type, [uti]);
195
212
  } else {
196
- u.push(name);
213
+ u.push(uti);
197
214
  }
198
215
  });
199
216
  }
200
217
 
201
- assignExtensions(name, extensions) {
218
+ /**
219
+ * Assign mime types to a UTI
220
+ * @param {string} uti
221
+ * @param {string[]} extensions
222
+ */
223
+ assignExtensions(uti, extensions) {
202
224
  extensions.forEach(ext => {
203
225
  const e = this.utiByFileNameExtension.get(ext);
204
226
  if (e === undefined) {
205
- this.utiByFileNameExtension.set(ext, [name]);
227
+ this.utiByFileNameExtension.set(ext, [uti]);
206
228
  } else {
207
- e.push(name);
229
+ e.push(uti);
208
230
  }
209
231
  });
210
232
  }
package/types/uti.d.mts CHANGED
@@ -5,7 +5,7 @@
5
5
  * @property {Map<string,UTI>} utiByFileNameExtension
6
6
  */
7
7
  export class UTIController {
8
- registry: Map<any, any>;
8
+ /** @type {Map<string,UTI>} */ registry: Map<string, UTI>;
9
9
  /** @type {Map<string,string[]>} */ utiByMimeType: Map<string, string[]>;
10
10
  /** @type {Map<string,string[]>} */ utiByFileNameExtension: Map<string, string[]>;
11
11
  /**
@@ -16,9 +16,9 @@ export class UTIController {
16
16
  /**
17
17
  * Lookup a given UTI.
18
18
  * @param {string} name UTI
19
- * @return {string|undefined} UTI for the given name or undefined if UTI is not present.
19
+ * @return {UTI|undefined} UTI for the given name or undefined if UTI is not present.
20
20
  */
21
- getUTI(name: string): string | undefined;
21
+ getUTI(name: string): UTI | undefined;
22
22
  /**
23
23
  * Lookup a UTIs for a mime type.
24
24
  * @param {string} mimeType mime type to get UTIs for
@@ -48,6 +48,64 @@ export class UTIController {
48
48
  * @return {boolean} ture if utils for file name are conformant
49
49
  */
50
50
  fileNameConformsTo(fileName: string, uti: string): boolean;
51
- assignMimeTypes(name: any, mimTypes: any): void;
52
- assignExtensions(name: any, extensions: any): void;
51
+ /**
52
+ * Assign mime types to a UTI
53
+ * @param {string} uti
54
+ * @param {string[]} mimeTypes
55
+ */
56
+ assignMimeTypes(uti: string, mimeTypes: string[]): void;
57
+ /**
58
+ * Assign mime types to a UTI
59
+ * @param {string} uti
60
+ * @param {string[]} extensions
61
+ */
62
+ assignExtensions(uti: string, extensions: string[]): void;
63
+ }
64
+ /**
65
+ * Object representing a UTI.
66
+ * @param {string} name
67
+ * @param {Set<UTI>} conforms
68
+ *
69
+ * @property {string} name
70
+ * @property {Set<UTI>} conforms
71
+ */
72
+ declare class UTI {
73
+ /**
74
+ * Object representing a UTI.
75
+ * @param {string} name
76
+ * @param {Set<UTI>} conforms
77
+ *
78
+ * @property {string} name
79
+ * @property {Set<UTI>} conforms
80
+ */
81
+ constructor(name: string, conforms: Set<UTI>);
82
+ name: string;
83
+ conforms: Set<UTI>;
84
+ /**
85
+ * Check for conformity.
86
+ * @param {UTI} other
87
+ * @return {boolean} true if other conforms to the receiver
88
+ */
89
+ conformsTo(other: UTI): boolean;
90
+ /**
91
+ * name of the UTI.
92
+ * @returns {string}
93
+ */
94
+ toString(): string;
95
+ /**
96
+ * Deliver JSON representation of the UTI.
97
+ * Sample result
98
+ * ```json
99
+ * {
100
+ * "name": "myUTI",
101
+ * "conformsTo": [ "uti1", "uti2"]
102
+ * }
103
+ * ```
104
+ * @return {{name:string, conforms: string[]}} json representation of the UTI
105
+ */
106
+ toJSON(): {
107
+ name: string;
108
+ conforms: string[];
109
+ };
53
110
  }
111
+ export {};