compile-mime-match
Compiles a function that matches a given MIME type. A faster alternative to type-is
for when the MIME type is known ahead of time.
Installation
// npm
npm install compile-mime-match --save
// yarn
yarn add compile-mime-match
Usage
const compileMimeMatch = ;const mimeMatch = ; ; // true; // true ; // false
Input Formats
type/subtype
Matches exactly the given MIME type (see the example above).
type/*
Matches any MIME type will the given type
.
const compileMimeMatch = ;const mimeMatch = ; ; // true; // true ; // false
*/subtype
Matches any MIME type will the given subtype
.
const compileMimeMatch = ;const mimeMatch = ; ; // true; // true ; // false
*/*
Matches any valid MIME type.
const compileMimeMatch = ;const mimeMatch = ; ; // true; // true ; // false; // false
+suffix
Matches any valid MIME type that ends with +suffix
.
const compileMimeMatch = ;const mimeMatch = ; ; // true; // true ; // false; // false
Array
compile-mime-match
also accepts an array of strings to match multiple types at the same time:
const compileMimeMatch = ;const mimeMatch = ; ; // true; // true; // true; // true ; // false