New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

uti

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uti

javascript implementation of a "Uniform Type Identifier" (UTI)

latest
Source
npmnpm
Version
8.11.2
Version published
Weekly downloads
1.7K
40.16%
Maintainers
1
Weekly downloads
 
Created
Source

npm License Typed with TypeScript bundlejs downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities

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-text

API

Table of Contents

UTIDeclaration

Type: Object

Properties

UTI

Object representing a UTI.

Parameters

Properties

name

Type: string

conforms

Type: Set<UTI>

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>} json representation of the UTI

UTIController

Registry of UTIs.

Properties

registry

Type: Map<string, UTI>

utiByMimeType

Type: Map<string, Array<string>>

utiByFileNameExtension

Type: Map<string, Array<string>>

register

Registers additional types.

Parameters

getUTI

Lookup a given UTI.

Parameters

Returns (UTI | undefined) UTI for the given name or undefined if UTI is not present.

getUTIsForMimeType

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

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

  • fileName string file to detect UTI for

Returns Array<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

  • fileName string file to detect UTI for
  • uti string to check conformance against

Returns boolean true if utils for file name are conformant

assignMimeTypes

Assign mime types to a UTI

Parameters

assignExtensions

Assign mime types to a UTI

Parameters

install

With npm do:

npm install uti

license

BSD-2-Clause

Keywords

MIME

FAQs

Package last updated on 12 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts