@robinpath/mime
v0.1.1
Published
> MIME type detection from extensions and file content, type classification, Content-Type building
Keywords
Readme
@robinpath/mime
MIME type detection from extensions and file content, type classification, Content-Type building
Why use this module?
The mime module lets you:
- Get MIME type from file extension
- Get extension from MIME type
- Detect MIME type from file content (magic bytes)
- Get charset for MIME type
- Check if MIME type is text-based
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/mimeQuick Start
No credentials needed — start using it right away:
mime.extension "image/png"Available Functions
| Function | Description |
|----------|-------------|
| mime.lookup | Get MIME type from file extension |
| mime.extension | Get extension from MIME type |
| mime.detect | Detect MIME type from file content (magic bytes) |
| mime.charset | Get charset for MIME type |
| mime.isText | Check if MIME type is text-based |
| mime.isImage | Check if MIME type is image |
| mime.isAudio | Check if MIME type is audio |
| mime.isVideo | Check if MIME type is video |
| mime.isFont | Check if MIME type is font |
| mime.isArchive | Check if MIME type is archive |
| mime.contentType | Build Content-Type header with charset |
| mime.allTypes | Get all known MIME type mappings |
Examples
Get extension from MIME type
mime.extension "image/png"Detect MIME type from file content (magic bytes)
mime.detect "./unknown_file"Get charset for MIME type
mime.charset "text/html"Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/mime";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
mime.extension "image/png"
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
