Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhermsmeier/node-mime-lib
MIME related utility functions
https://github.com/jhermsmeier/node-mime-lib
decoder encoder encoding mime mime-encoding mime-types quoted-printable
Last synced: 2 months ago
JSON representation
MIME related utility functions
- Host: GitHub
- URL: https://github.com/jhermsmeier/node-mime-lib
- Owner: jhermsmeier
- License: mit
- Created: 2012-05-11T01:12:09.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2018-04-28T13:27:34.000Z (over 6 years ago)
- Last Synced: 2024-10-11T07:34:25.100Z (3 months ago)
- Topics: decoder, encoder, encoding, mime, mime-encoding, mime-types, quoted-printable
- Language: JavaScript
- Homepage:
- Size: 68.4 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MIME Library
[![npm](https://img.shields.io/npm/v/mime-lib.svg?style=flat-square)](https://npmjs.com/mime-lib)
[![npm](https://img.shields.io/npm/l/mime-lib.svg?style=flat-square)](https://npmjs.com/mime-lib)
[![npm downloads](https://img.shields.io/npm/dm/mime-lib.svg?style=flat-square)](https://npmjs.com/mime-lib)
[![build status](https://img.shields.io/travis/jhermsmeier/node-mime-lib.svg?style=flat-square)](https://travis-ci.org/jhermsmeier/node-mime-lib)## Install via [npm](https://npmjs.com/package/mime-lib)
```sh
$ npm install mime-lib
```## Usage
### MIME type lookup
```javascript
mime.type('html') // => text/html
mime.type('mp4') // => video/mp4
mime.type('nonexistant') // => application/octet-stream
```### MIME extension lookup
```javascript
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](http://en.wikipedia.org/wiki/MIME#Encoded-Word).
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](http://tools.ietf.org/html/rfc5322#section-2.1.1).
Returns string.
See [jhermsmeier/node-foldline](https://github.com/jhermsmeier/node-foldline)