UNPKG

motion

Version:

motion - moving development forward

75 lines (74 loc) 5.05 kB
{ "_args": [ [ "content-type@https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "content-type@>=1.0.1 <1.1.0", "_id": "content-type@1.0.1", "_inCache": true, "_location": "/content-type", "_phantomChildren": {}, "_requested": { "name": "content-type", "raw": "content-type@https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", "rawSpec": "https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", "scope": null, "spec": "https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", "type": "remote" }, "_requiredBy": [ "/express" ], "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", "_shasum": "a19d2247327dc038050ce622b7a154ec59c5e600", "_shrinkwrap": null, "_spec": "content-type@https://registry.npmjs.org/content-type/-/content-type-1.0.1.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "email": "doug@somethingdoug.com", "name": "Douglas Christopher Wilson" }, "bugs": { "url": "https://github.com/jshttp/content-type/issues" }, "dependencies": {}, "description": "Create and parse HTTP Content-Type header", "devDependencies": { "istanbul": "0.3.5", "mocha": "~1.21.5" }, "engines": { "node": ">= 0.6" }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], "homepage": "https://github.com/jshttp/content-type#readme", "keywords": [ "content-type", "http", "req", "res", "rfc7231" ], "license": "MIT", "name": "content-type", "optionalDependencies": {}, "readme": "# content-type\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\nCreate and parse HTTP Content-Type header according to RFC 7231\n\n## Installation\n\n```sh\n$ npm install content-type\n```\n\n## API\n\n```js\nvar contentType = require('content-type')\n```\n\n### contentType.parse(string)\n\n```js\nvar obj = contentType.parse('image/svg+xml; charset=utf-8')\n```\n\nParse a content type string. This will return an object with the following\nproperties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):\n\n - `type`: The media type (the type and subtype, always lower case).\n Example: `'image/svg+xml'`\n\n - `parameters`: An object of the parameters in the media type (name of parameter\n always lower case). Example: `{charset: 'utf-8'}`\n\nThrows a `TypeError` if the string is missing or invalid.\n\n### contentType.parse(req)\n\n```js\nvar obj = contentType.parse(req)\n```\n\nParse the `content-type` header from the given `req`. Short-cut for\n`contentType.parse(req.headers['content-type'])`.\n\nThrows a `TypeError` if the `Content-Type` header is missing or invalid.\n\n### contentType.parse(res)\n\n```js\nvar obj = contentType.parse(res)\n```\n\nParse the `content-type` header set on the given `res`. Short-cut for\n`contentType.parse(res.getHeader('content-type'))`.\n\nThrows a `TypeError` if the `Content-Type` header is missing or invalid.\n\n### contentType.format(obj)\n\n```js\nvar str = contentType.format({type: 'image/svg+xml'})\n```\n\nFormat an object into a content type string. This will return a string of the\ncontent type for the given object with the following properties (examples are\nshown that produce the string `'image/svg+xml; charset=utf-8'`):\n\n - `type`: The media type (will be lower-cased). Example: `'image/svg+xml'`\n\n - `parameters`: An object of the parameters in the media type (name of the\n parameter will be lower-cased). Example: `{charset: 'utf-8'}`\n\nThrows a `TypeError` if the object contains an invalid type or parameter names.\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/content-type.svg\n[npm-url]: https://npmjs.org/package/content-type\n[node-version-image]: https://img.shields.io/node/v/content-type.svg\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/content-type/master.svg\n[travis-url]: https://travis-ci.org/jshttp/content-type\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-type/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/content-type\n[downloads-image]: https://img.shields.io/npm/dm/content-type.svg\n[downloads-url]: https://npmjs.org/package/content-type\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/jshttp/content-type.git" }, "scripts": { "test": "mocha --reporter spec --check-leaks --bail test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, "version": "1.0.1" }