Modules@robinpath/mime

@robinpath/mime

0.1.1Public

MIME type detection from extensions and file content, type classification, Content-Type building

@robinpath/mime

MIME type detection from extensions and file content, type classification, Content-Type building

Category Functions Auth License

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/mime

Quick Start

No credentials needed — start using it right away:

mime.extension "image/png"

Available Functions

FunctionDescription
mime.lookupGet MIME type from file extension
mime.extensionGet extension from MIME type
mime.detectDetect MIME type from file content (magic bytes)
mime.charsetGet charset for MIME type
mime.isTextCheck if MIME type is text-based
mime.isImageCheck if MIME type is image
mime.isAudioCheck if MIME type is audio
mime.isVideoCheck if MIME type is video
mime.isFontCheck if MIME type is font
mime.isArchiveCheck if MIME type is archive
mime.contentTypeBuild Content-Type header with charset
mime.allTypesGet 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

License

MIT

Versions (1)

VersionTagPublished
0.1.1latestyesterday
Install
$ robinpath install @robinpath/mime
Version0.1.1
LicenseMIT
Unpacked Size5.3 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

utilities