UNPKG

motion

Version:

motion - moving development forward

74 lines (73 loc) 4.42 kB
{ "_args": [ [ "vary@https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "vary@>=1.0.0 <2.0.0", "_id": "vary@1.1.0", "_inCache": true, "_location": "/vary", "_phantomChildren": {}, "_requested": { "name": "vary", "raw": "vary@https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", "rawSpec": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", "scope": null, "spec": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", "type": "remote" }, "_requiredBy": [ "/cors" ], "_resolved": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", "_shasum": "e1e5affbbd16ae768dd2674394b9ad3022653140", "_shrinkwrap": null, "_spec": "vary@https://registry.npmjs.org/vary/-/vary-1.1.0.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "email": "doug@somethingdoug.com", "name": "Douglas Christopher Wilson" }, "bugs": { "url": "https://github.com/jshttp/vary/issues" }, "dependencies": {}, "description": "Manipulate the HTTP Vary header", "devDependencies": { "istanbul": "0.3.21", "mocha": "2.3.3", "supertest": "1.1.0" }, "engines": { "node": ">= 0.8" }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], "homepage": "https://github.com/jshttp/vary#readme", "keywords": [ "http", "res", "vary" ], "license": "MIT", "name": "vary", "optionalDependencies": {}, "readme": "# vary\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\nManipulate the HTTP Vary header\n\n## Installation\n\n```sh\n$ npm install vary\n```\n\n## API\n\n```js\nvar vary = require('vary')\n```\n\n### vary(res, field)\n\nAdds the given header `field` to the `Vary` response header of `res`.\nThis can be a string of a single field, a string of a valid `Vary`\nheader, or an array of multiple fields.\n\nThis will append the header if not already listed, otherwise leaves\nit listed in the current location.\n\n```js\n// Append \"Origin\" to the Vary header of the response\nvary(res, 'Origin')\n```\n\n### vary.append(header, field)\n\nAdds the given header `field` to the `Vary` response header string `header`.\nThis can be a string of a single field, a string of a valid `Vary` header,\nor an array of multiple fields.\n\nThis will append the header if not already listed, otherwise leaves\nit listed in the current location. The new header string is returned.\n\n```js\n// Get header string appending \"Origin\" to \"Accept, User-Agent\"\nvary.append('Accept, User-Agent', 'Origin')\n```\n\n## Examples\n\n### Updating the Vary header when content is based on it\n\n```js\nvar http = require('http')\nvar vary = require('vary')\n\nhttp.createServer(function onRequest(req, res) {\n // about to user-agent sniff\n vary(res, 'User-Agent')\n\n var ua = req.headers['user-agent'] || ''\n var isMobile = /mobi|android|touch|mini/i.test(ua)\n\n // serve site, depending on isMobile\n res.setHeader('Content-Type', 'text/html')\n res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user')\n})\n```\n\n## Testing\n\n```sh\n$ npm test\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/vary.svg\n[npm-url]: https://npmjs.org/package/vary\n[node-version-image]: https://img.shields.io/node/v/vary.svg\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/vary/master.svg\n[travis-url]: https://travis-ci.org/jshttp/vary\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/vary/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/vary\n[downloads-image]: https://img.shields.io/npm/dm/vary.svg\n[downloads-url]: https://npmjs.org/package/vary\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/jshttp/vary.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks 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/" }, "version": "1.1.0" }