Mimoza
Mimoza is a tiny but comprehensive MIME tools library. Features:
- Resolving mime type by file path/name/extention (with fallback for unknown cases).
- Finding file extention by mime type.
- Checking if mime type (or file) can be compressed.
- Checking if mime type has text content (if you wish to force UTF-8 encoding)
- You can have multimple instances with different configs.
- Works in browser too (AMD module).
See detailed API docs.
Installation
for node.js:
npm install mimoza
for browser (AMD module):
bower install mimoza
Example
var Mimoza = ;// Use builtin methods:Mimoza; // -> '.oga'Mimoza; // -> 'audio/ogg'Mimoza; // -> 'audio/ogg'Mimoza; // -> 'audio/ogg'Mimoza; // -> 'audio/ogg'Mimoza; // -> trueMimoza; // -> falseMimoza; // -> trueMimoza; // -> trueMimoza; // -> trueMimoza; // -> false// Define your own instancevar mime =defaultType: 'hard/core' // mime type for unknown extentionspreloaded: true // load default rules;// instances are customizeablemime;mime; // -> '.baz'mime; // -> 'foo/bar'mime; // -> 'foo/bar'// unknown file types, with default & custom fallbackmime; // -> 'hard/core'mime; // -> 'soft/core'