Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Detect the mime type of a Buffer
, ReadStream
, file path and file name.
$ npm install mime-kind --save
const fs = require('fs');
const mime = require('mime-kind');
mime('c:/anonim.jpeg'); // -> { ext: 'jpeg', mime: 'image/jpeg' }
mime('.fakeext'); // -> null
mime(fs.createReadStream('./anonim.jpg')); // -> { ext: 'jpeg', mime: 'image/jpeg' }
Returns an object (or null
when no match) with:
ext
- file typemime
- the MIME typeBuffer
, ReadStream
, file path or file name.String
or Object
with value which will be returned if no match will be found. If defaultValue
is incorrect returns null
.const mime = require('mime-kind');
mime('.fakeext', 'application/octet-stream'); // -> { ext: 'bin', mime: 'application/octet-stream' }
mime('.fakeext', { ext: 'mp4', mime: 'video/mp4' }); // -> { ext: 'mp4', mime: 'video/mp4' }
mime('.fakeext', 'ogg'); // -> { ext: 'ogg', mime: 'audio/ogg' }
// but
mime('.fakeext', 'ogg3'); // -> null
mime('.fakeext', { ext: 'fake', mime: 'fake/fake' }); // -> { ext: 'fake', mime: 'fake/fake' }
The MIT License (MIT)
Copyright (c) 2015-2016 Alexey Bystrov
FAQs
Detect the MIME type of a Buffer, Uint8Array, ArrayBuffer, ReadableStream, file path and file name, with async method.
The npm package mime-kind receives a total of 21,896 weekly downloads. As such, mime-kind popularity was classified as popular.
We found that mime-kind demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.