npm.io
0.1.0 • Published 11 years ago

parse-mime

Licence
MIT
Version
0.1.0
Deps
1
Vulns
0
Weekly
0

parse-mime

A centralized parsing module that can be extended to handle any mime type

Installation

With packin: packin add jkroso/parse-mime

then in your app:

var parse = require('parse-mime')

API

parse(mime, data)

Takes a mimetype string and some data and returns the parsed value. If it doesn't know how to parse the given mimetype it will just return the data unchanged

parse('application/json', '[1,2,3]') // => [1,2,3]
parse.define(mime, fn)

Define a parser for a new mimetype

parse.define('application/edn', JSON.parse)
parse('application/edn', '[1,2,3]') // => [1,2,3]

If the mimetype has already been defined then it will throw an error

Keywords