Home

Awesome

mime

Fast, robust, standards-compliant MIME decoder. Ships with extensive tests and fuzz tests.

Installation

npm install @ronomon/mime

Fast

Robust

Standards-Compliant

Usage

var MIME = require('@ronomon/mime');

// Instantiate a new mime instance (no decoding will take place):

var mime = new MIME.Message(buffer);

// Decoding will take place when the following getter properties are accessed.
// These getter properties may throw an exception for malformed MIME data.

mime.headers;             // { 'received': [<Buffer>] }
mime.body;                // <Buffer>

mime.from;                // [ { name: <String>, email: <String> } ]
mime.sender;              //   { name: <String>, email: <String> } / undefined
mime.replyTo;             // [ { name: <String>, email: <String> } ]
mime.to;                  // [ { name: <String>, email: <String> } ]
mime.cc;                  // [ { name: <String>, email: <String> } ]
mime.bcc;                 // [ { name: <String>, email: <String> } ]

mime.messageID;           //   <String> / undefined
mime.references;          // [ <String>, <String> ]
mime.inReplyTo;           // [ <String>, <String> ]

mime.date;                // <Unix Timestamp Integer>
mime.subject;             // <String>

mime.contentDisposition;  // { value: <String>, parameters: {} }
mime.contentType;         // { value: <String>, parameters: {} }
mime.contentID;           // <String> / undefined
mime.filename;            // <String> / undefined

mime.parts;               // [ <MIME.Message>, <MIME.Message> ]

Tests

To run all included tests and fuzz tests:

node test.js