Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (62 sloc) 2.28 KB

MIME Library

npm npm npm downloads build status

Install via npm

$ npm install mime-lib

Usage

MIME type lookup

mime.type('html')        // => text/html
mime.type('mp4')         // => video/mp4
mime.type('nonexistant') // => application/octet-stream

MIME extension lookup

mime.extension('text/html')   // => [ 'htm', 'html' ]
mime.extension('nonexistant') // => undefined

mime.encodeBase64( input, charset )

String | Buffer input String charset (optional)

Base64 encodes a buffer or string. Returns string.

mime.decodeBase64( input, charset )

String input String charset (optional)

Decodes a base64 encoded string. Returns string or buffer.

mime.encodeQP( input, multibyte, wordMode )

String input Boolean multibyte (optional) Boolean wordMode (optional)

Encodes a string into Quoted-printable format. Returns string.

mime.decodeQP( input, multibyte, wordMode )

String input Boolean multibyte (optional) Boolean wordMode (optional)

Decodes a string from Quoted-printable format. Returns string.

mime.encodeWord( input, type, charset )

String input String type (optional) String charset (optional)

Encodes a string into mime encoded word format. Returns string.

mime.decodeWord( input )

String input

Decodes a string from mime encoded word format. Returns string.

mime.foldLine( input, maxLength, hardWrap )

String input Number maxLength (optional) Boolean hardWrap (optional)

Folds a long line according to the RFC 5322. Returns string. See jhermsmeier/node-foldline