uti v8.7.0
uti
Uniform Type Identifier
Please see ars technica article for a description about the principles of UTIs.
For a list of known UTIs please see here
example
myuti.js
import { UTIController } from "uti";
const uc = new UTIController();
const doesConformTo = uc.conformsTo("public.image", "public.data");
console.log("doesConformTo: " + doesConformTo);
console.log(uc.getUTIsForFileName("a.txt")[0]);Output
doesConformTo: true
public.plain-textAPI
Table of Contents
UTI
Object representing a UTI.
Parameters
Properties
name
Type: string
conforms
conformsTo
Check for conformity.
Parameters
Returns boolean true if other conforms to the receiver
toString
name of the UTI.
Returns string
toJSON
Deliver JSON representation of the UTI. Sample result
{
"name": "myUTI",
"conformsTo": [ "uti1", "uti2"]
}Returns {name: string, conforms: Array[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)} json representation of the UTI
UTIController
Registry of UTIs.
Properties
registry
utiByMimeType
Type: Map<string, Array[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>
utiByFileNameExtension
Type: Map<string, Array[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>
register
Registers additional types.
Parameters
getUTI
Lookup a given UTI.
Parameters
namestring UTI
Returns (UTI | undefined) UTI for the given name or undefined if UTI is not present.
getUTIsForMimeType
Lookup a UTIs for a mime type.
Parameters
mimeTypestring mime type to get UTIs for
Returns Array[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) UTIs for the given mime type
getUTIsForFileName
Lookup a UTI for a file name. First the file name extension is extracted. Then a lookup in the registered UTIs for file name extension is executed.
Parameters
fileNamestring file to detect UTI for
Returns Array[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) UTIs for the given fileName
conformsTo
Check whenever two UTI are conformant. If a conforms to b and b conforms to c then a also conforms to c.
Parameters
Returns boolean true if UTI a conforms to UTI b.
fileNameConformsTo
Lookup a UTI for a file name and check conformance.
Parameters
Returns boolean true if utils for file name are conformant
assignMimeTypes
Assign mime types to a UTI
Parameters
utistringmimeTypesArray[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
assignExtensions
Assign mime types to a UTI
Parameters
utistringextensionsArray[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
install
With npm do:
npm install utilicense
BSD-2-Clause
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago