mime-types-no-nodejs
v0.9.2
Published
Typescript mime types to doc type mapping.
Downloads
12
Readme
About
Convert mime type to and from document type.
Reference:
Credits
Source modified from jshttp/mime-types.
Why?
- Removed Node.js dependency.
See #50.
- Re-write in typescript.
Qick start
install dependency
npm install mime-types-no-nodejs
run test (with source)
npm install
npm test
API
import Mime from 'mime-types-no-nodejs';
- lookup()
Lookup the MIME type for a file / path extension.
/**
* @param {string} path
* @return {boolean|string} false when failed
*/
function lookup (path);
- extension()
Get the default extension for a MIME type.
/**
* @param {string} type
* @return {boolean|string} doc type or false if failed
*/
function extension (type);
Testing code snippet:
// test/no-node.js
import Mime from '../index';
it('mime2type', () => {
assert.equal(Mime.extension('image/png;base64'), 'png');
});
it('type2mime', () => {
assert.equal(Mime.lookup('png'), 'image/png');
});