{
  "name": "type-is",
  "description": "Infer the content-type of a request.",
  "version": "1.6.9",
  "contributors": [
    {
      "name": "Douglas Christopher Wilson",
      "email": "doug@somethingdoug.com"
    },
    {
      "name": "Jonathan Ong",
      "email": "me@jongleberry.com",
      "url": "http://jongleberry.com"
    }
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git://github.com/jshttp/type-is"
  },
  "dependencies": {
    "media-typer": "0.3.0",
    "mime-types": "~2.1.7"
  },
  "devDependencies": {
    "istanbul": "0.3.21",
    "mocha": "~1.21.5"
  },
  "engines": {
    "node": ">= 0.6"
  },
  "files": [
    "LICENSE",
    "HISTORY.md",
    "index.js"
  ],
  "scripts": {
    "test": "mocha --reporter spec --check-leaks --bail test/",
    "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
    "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
  },
  "keywords": [
    "content",
    "type",
    "checking"
  ],
  "readme": "# type-is\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Node.js Version][node-version-image]][node-version-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nInfer the content-type of a request.\n\n### Install\n\n```sh\n$ npm install type-is\n```\n\n## API\n\n```js\nvar http = require('http')\nvar is   = require('type-is')\n\nhttp.createServer(function (req, res) {\n  var istext = is(req, ['text/*'])\n  res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text')\n})\n```\n\n### type = is(request, types)\n\n`request` is the node HTTP request. `types` is an array of types.\n\n```js\n// req.headers.content-type = 'application/json'\n\nis(req, ['json'])             // 'json'\nis(req, ['html', 'json'])     // 'json'\nis(req, ['application/*'])    // 'application/json'\nis(req, ['application/json']) // 'application/json'\n\nis(req, ['html']) // false\n```\n\n### is.hasBody(request)\n\nReturns a Boolean if the given `request` has a body, regardless of the\n`Content-Type` header.\n\n```js\nif (is.hasBody(req)) {\n  // read the body, since there is one\n\n  req.on('data', function (chunk) {\n    // ...\n  })\n}\n```\n\n### type = is.is(mediaType, types)\n\n`mediaType` is the [media type](https://tools.ietf.org/html/rfc6838) string. `types` is an array of types.\n\n```js\nvar mediaType = 'application/json'\n\nis.is(mediaType, ['json'])             // 'json'\nis.is(mediaType, ['html', 'json'])     // 'json'\nis.is(mediaType, ['application/*'])    // 'application/json'\nis.is(mediaType, ['application/json']) // 'application/json'\n\nis.is(mediaType, ['html']) // false\n```\n\n### Each type can be:\n\n- An extension name such as `json`. This name will be returned if matched.\n- A mime type such as `application/json`.\n- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`. The full mime type will be returned if matched.\n- A suffix such as `+json`. This can be combined with a wildcard such as `*/vnd+json` or `application/*+json`. The full mime type will be returned if matched.\n\n`false` will be returned if no type matches or the content type is invalid.\n\n`null` will be returned if the request does not have a body.\n\n## Examples\n\n#### Example body parser\n\n```js\nvar is = require('type-is');\n\nfunction bodyParser(req, res, next) {\n  if (!is.hasBody(req)) {\n    return next()\n  }\n\n  switch (is(req, ['urlencoded', 'json', 'multipart'])) {\n    case 'urlencoded':\n      // parse urlencoded body\n      throw new Error('implement urlencoded body parsing')\n      break\n    case 'json':\n      // parse json body\n      throw new Error('implement json body parsing')\n      break\n    case 'multipart':\n      // parse multipart body\n      throw new Error('implement multipart body parsing')\n      break\n    default:\n      // 415 error code\n      res.statusCode = 415\n      res.end()\n      return\n  }\n}\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/type-is.svg\n[npm-url]: https://npmjs.org/package/type-is\n[node-version-image]: https://img.shields.io/node/v/type-is.svg\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/type-is/master.svg\n[travis-url]: https://travis-ci.org/jshttp/type-is\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/type-is/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/type-is.svg\n[downloads-url]: https://npmjs.org/package/type-is\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/jshttp/type-is/issues"
  },
  "homepage": "https://github.com/jshttp/type-is",
  "_id": "type-is@1.6.9",
  "dist": {
    "shasum": "3502988922d0ab3eece401c5c3be19242673dbca"
  },
  "_from": "type-is@~1.6.6",
  "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.9.tgz"
}
