Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mime-tree

Josh-McFarlin2.8kMIT0.1.4TypeScript support: included

A helper for quickly determining the file type of a buffer

mime type, mime, image

readme

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);

changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

Fix

  • Fixed incorrect check implementation

Added

  • Added tests for every image type to verify implementation

[0.1.3] - 2022-02-17

Documentation

  • Mark package as side-effect free

[0.1.2] - 2022-02-17

Documentation

  • Add more info to README.md

[0.1.1] - 2022-02-17

Added

  • First public release.

[0.1.0] - 2022-02-17

Fix

  • Fix Rollup issues preventing publishing