0.1.0 • Published 6 months ago

@gladiolus/mime v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@gladiolus/mime

In general, the suffix of a file should reflect its mime type to some extent. But no matter what, adding another dimension of judgment can always improve the accuracy somewhat.

Determining the MIME type for a file

Install

npm install @gladiolus/mime

Usage

commonjs

const { findMime } = require('@gladiolus/mime');

findMime('README.md'); // => 'text/markdown'

esm

import { findMime } from '@gladiolus/mime';

findMime('README.md'); // => 'text/markdown'

API

overloadsdescription
function findMime(filename: string): string \| nullFind mime type of file by filename
function findMime(beginBytes: ToBeginBytes): string \| nullFind mime type of file by begin bytes
function findMime(filename: string, beginBytes: ToBeginBytes): string \| nullFind mime type of file by filename or begin bytes.It will use begin bytes first (if any), then filename if failed.

Note: type ToBeginBytes = ArrayLike<number> | Iterable<number>

0.1.0

6 months ago