javascript implementation of a "Uniform Type Identifier" (UTI)
npm install uti









Please see ars technica article for a description about the principles of UTIs.
For a list of known UTIs please see here
``javascript
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
`txt`
doesConformTo: true
public.plain-text
* UTIDeclaration
* Properties
* UTI
* Parameters
* Properties
* name
* conforms
* conformsTo
* Parameters
* toString
* toJSON
* UTIController
* Properties
* registry
* utiByMimeType
* utiByFileNameExtension
* register
* Parameters
* getUTI
* Parameters
* getUTIsForMimeType
* Parameters
* getUTIsForFileName
* Parameters
* conformsTo
* Parameters
* fileNameConformsTo
* Parameters
* assignMimeTypes
* Parameters
* assignExtensions
* Parameters
Type: Object
* name string conformsTo
* (string | Array<string>)? mimeType
* (string | Array<string>)? fileNameExtension
* (string | Array<string>)?
Object representing a UTI.
* name string conforms
* Set<UTI>
* name string conforms
* Set<UTI>
Type: string
Check for conformity.
#### Parameters
Returns boolean true if other conforms to the receiver
name of the UTI.
Returns string
Deliver JSON representation of the UTI.
Sample result
`json`
{
"name": "myUTI",
"conformsTo": [ "uti1", "uti2"]
}
Returns {name: string, conforms: Array<string>} json representation of the UTI
Registry of UTIs.
* registry Map<string, UTI> utiByMimeType
* Map<string, UTI> utiByFileNameExtension
* Map<string, UTI>
Type: Map<string, Array<string>>
Type: Map<string, Array<string>>
Registers additional types.
#### Parameters
* types Array<UTIDeclaration>
Lookup a given UTI.
#### Parameters
* name string UTI
Returns (UTI | undefined) UTI for the given name or undefined if UTI is not present.
Lookup a UTIs for a mime type.
#### Parameters
* mimeType string mime type to get UTIs for
Returns Array<string> UTIs for the given mime type
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
* fileName string file to detect UTI for
Returns Array<string> UTIs for the given fileName
Check whenever two UTI are conformant.
If a conforms to b and b conforms to c then a also conforms to c.
#### Parameters
* a string first UTIb
* string second UTI
Returns boolean true if UTI a conforms to UTI b.
Lookup a UTI for a file name and check conformance.
#### Parameters
* fileName string file to detect UTI foruti
* string to check conformance against
Returns boolean true if utils for file name are conformant
Assign mime types to a UTI
#### Parameters
* uti string mimeTypes
* Array<string>
Assign mime types to a UTI
#### Parameters
* uti string extensions
* Array<string>
With npm do:
`shell``
npm install uti
BSD-2-Clause