mimext
v0.1.8
Published
mime type to extension and the reverse map
Downloads
18
Maintainers
Readme
mimext
documentation - install - test
sample
var mimext = require('mimext');
console.log('%s %s %s\n%j\n',
mimext('js'),
mimext('.json'),
mimext('file.coffee'),
mimext('text/coffeescript'),
mimext(mimext('filename.mp3'))
);
// application/javascript application/json text/coffeescript
// {"extensions":["coffee","litcoffee"]}
// { source: 'iana',
// compressible: false,
// extensions: [ 'mpga', 'mp2', 'mp2a', 'mp3', 'm2a', 'm3a' ] }
documentation
The module.exports
a function
mimext
function mimext(string|object input)
arguments
input
, type string or object to check
when
input
is an object, it should have a propertyextensions
with an array of the extensions for that mime type. Look at mime-db for more information.input
is a string, can have a dot. If has a slash it will be mapped to a mime type directly
returns
- mime type of for the string|object given
- properties of the mime type given as string
mimext properties
mimext.mimes
all mime types given by mime-dbmimext.extnames
the inverse mapping from extension to mime type
install
With npm
$ npm install mimext
test
$ npm t
ext
✓ should map extension (no dot) to mimeType
✓ should map extension (with dot) to mimeType
filenames
✓ should map filename to mimeType
mime
✓ should map mimeType to its specs
✓ should map mimeType to extensions
5 passing (14ms)
license
The MIT License (MIT)
Copyright (c) 2015-present Javier Carrillo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.