npm.io
0.1.4 • Published 4 years ago

mime-tree

Licence
MIT
Version
0.1.4
Deps
0
Size
8 kB
Vulns
0
Weekly
0

mime-tree

Intro

A helper for quickly determining the file type of a buffer.

This library is pure JavaScript, any can run in Node, the browser, or anywhere else JavaScript runs. This library is exported in CommonJS and ES Modules.

Compared to other libraries that iterate through multiple arrays to find the mime type, this helper detects mime type by looping through a single object.

Supported File Types

  • JPEG
  • PNG
  • GIF
  • WEBP
  • BMP
  • TIFF
  • AVIF

How to use

Install

To install this library, use on of the following commands:

npm install -S mime-tree
yarn add mime-tree
Use
import mimeFromBuffer from "mime-tree";

const image: Uint8Array = ...;

const mimeType = mimeFromBuffer(image);

Keywords