{"name":"negotiator","description":"HTTP content negotiation","dist-tags":{"latest":"0.6.3"},"versions":{"0.6.3":{"name":"negotiator","description":"HTTP content negotiation","version":"0.6.3","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jshttp/negotiator.git"},"devDependencies":{"eslint":"7.32.0","eslint-plugin-markdown":"2.2.1","mocha":"9.1.3","nyc":"15.1.0"},"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec --check-leaks --bail test/","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"gitHead":"40a5acb0c878cca951bc44d1d9e2ab1f90ae813e","bugs":{"url":"https://github.com/jshttp/negotiator/issues"},"_id":"negotiator@0.6.3","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==","shasum":"58e323a72fedc0d6f9cd4d31fe49f51479590ccd","tarball":"http://localhost:4260/negotiator/negotiator-0.6.3.tgz","fileCount":9,"unpackedSize":27375,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7LRVCRA9TVsSAnZWagAADXQQAIRjFiv7jUhvg/7FE3tH\nLDOBadiC2gYFtN86BitJeUZGhyGMn0kkJQ4bxxRmZHfJBS3XGSDiPd3pRPWl\nyAB2HHJ3JpXS3pM1CdnUvxI6aLg/EVwO/qISHoFLYfx86M721ZPOoCs1mUDy\nVL0AZTR55cCIaF/5sl4CWKxWTnX2CUltGDJKKQsXo+eKuLhNZ8G76PdXABoG\n1gDpwALLFaAW0CYh/sIy6st9JTTx4gHkVcPHZLtsmeyzdKGMxzaXLpU6/xhr\nP2/lBMg6t8xRtu4e76/hzBJSaRnL78EXLndwYbdHXABoFkzM5qpLD+UY5eNT\nMsDK/aHTxnIIyg8LBC8qPagdH7sB8MXOnMzR7gKOjHzPUNqqQVpyCkc/ipaE\nsKNh0AfEJ6qxfht6DYT1sLGSCmDhX3ivleOiIj+nKSAeNa/rk1Hvsfj2FNQN\nKjFidMLwB04+l9chMTNEtNq/Pxk9+zen27vD0JkuqwXovgHvESRWGtlE47M8\npxi4gBypqHMUe9G6FO3RZ7pzLzkfXfwaKDWY28/TEskJO8rZsvsb87JL+BK1\nymaGSP/G7kQROLaTIY5/Oa5KbXI20DBvkkY77BofAOS/H/CTrFBe/vtoH3YM\nmuaNzt2miXUxKFQszMBL0uWjy9K49Yuf5+cHKPsuKydKDG/FeOaGLF6Eu9SI\nhK4i\r\n=du2Y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCwWK0qSZqF/rTSc9yQVnO06hqkMpn44qT6AjizctXUeQIhAJ6VHibmzze9aOy2LJSVenGWZcWx8zUFvmENe9uhlhZr"}]},"directories":{},"_hasShrinkwrap":false}},"readme":"# negotiator\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][github-actions-ci-image]][github-actions-ci-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nAn HTTP content negotiator for Node.js\n\n## Installation\n\n```sh\n$ npm install negotiator\n```\n\n## API\n\n```js\nvar Negotiator = require('negotiator')\n```\n\n### Accept Negotiation\n\n```js\navailableMediaTypes = ['text/html', 'text/plain', 'application/json']\n\n// The negotiator constructor receives a request object\nnegotiator = new Negotiator(request)\n\n// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8'\n\nnegotiator.mediaTypes()\n// -> ['text/html', 'image/jpeg', 'application/*']\n\nnegotiator.mediaTypes(availableMediaTypes)\n// -> ['text/html', 'application/json']\n\nnegotiator.mediaType(availableMediaTypes)\n// -> 'text/html'\n```\n\nYou can check a working example at `examples/accept.js`.\n\n#### Methods\n\n##### mediaType()\n\nReturns the most preferred media type from the client.\n\n##### mediaType(availableMediaType)\n\nReturns the most preferred media type from a list of available media types.\n\n##### mediaTypes()\n\nReturns an array of preferred media types ordered by the client preference.\n\n##### mediaTypes(availableMediaTypes)\n\nReturns an array of preferred media types ordered by priority from a list of\navailable media types.\n\n### Accept-Language Negotiation\n\n```js\nnegotiator = new Negotiator(request)\n\navailableLanguages = ['en', 'es', 'fr']\n\n// Let's say Accept-Language header is 'en;q=0.8, es, pt'\n\nnegotiator.languages()\n// -> ['es', 'pt', 'en']\n\nnegotiator.languages(availableLanguages)\n// -> ['es', 'en']\n\nlanguage = negotiator.language(availableLanguages)\n// -> 'es'\n```\n\nYou can check a working example at `examples/language.js`.\n\n#### Methods\n\n##### language()\n\nReturns the most preferred language from the client.\n\n##### language(availableLanguages)\n\nReturns the most preferred language from a list of available languages.\n\n##### languages()\n\nReturns an array of preferred languages ordered by the client preference.\n\n##### languages(availableLanguages)\n\nReturns an array of preferred languages ordered by priority from a list of\navailable languages.\n\n### Accept-Charset Negotiation\n\n```js\navailableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5']\n\nnegotiator = new Negotiator(request)\n\n// Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2'\n\nnegotiator.charsets()\n// -> ['utf-8', 'iso-8859-1', 'utf-7']\n\nnegotiator.charsets(availableCharsets)\n// -> ['utf-8', 'iso-8859-1']\n\nnegotiator.charset(availableCharsets)\n// -> 'utf-8'\n```\n\nYou can check a working example at `examples/charset.js`.\n\n#### Methods\n\n##### charset()\n\nReturns the most preferred charset from the client.\n\n##### charset(availableCharsets)\n\nReturns the most preferred charset from a list of available charsets.\n\n##### charsets()\n\nReturns an array of preferred charsets ordered by the client preference.\n\n##### charsets(availableCharsets)\n\nReturns an array of preferred charsets ordered by priority from a list of\navailable charsets.\n\n### Accept-Encoding Negotiation\n\n```js\navailableEncodings = ['identity', 'gzip']\n\nnegotiator = new Negotiator(request)\n\n// Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5'\n\nnegotiator.encodings()\n// -> ['gzip', 'identity', 'compress']\n\nnegotiator.encodings(availableEncodings)\n// -> ['gzip', 'identity']\n\nnegotiator.encoding(availableEncodings)\n// -> 'gzip'\n```\n\nYou can check a working example at `examples/encoding.js`.\n\n#### Methods\n\n##### encoding()\n\nReturns the most preferred encoding from the client.\n\n##### encoding(availableEncodings)\n\nReturns the most preferred encoding from a list of available encodings.\n\n##### encodings()\n\nReturns an array of preferred encodings ordered by the client preference.\n\n##### encodings(availableEncodings)\n\nReturns an array of preferred encodings ordered by priority from a list of\navailable encodings.\n\n## See Also\n\nThe [accepts](https://npmjs.org/package/accepts#readme) module builds on\nthis module and provides an alternative interface, mime type validation,\nand more.\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/negotiator.svg\n[npm-url]: https://npmjs.org/package/negotiator\n[node-version-image]: https://img.shields.io/node/v/negotiator.svg\n[node-version-url]: https://nodejs.org/en/download/\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/negotiator/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/negotiator?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/negotiator.svg\n[downloads-url]: https://npmjs.org/package/negotiator\n[github-actions-ci-image]: https://img.shields.io/github/workflow/status/jshttp/negotiator/ci/master?label=ci\n[github-actions-ci-url]: https://github.com/jshttp/negotiator/actions/workflows/ci.yml\n","repository":{"type":"git","url":"git+https://github.com/jshttp/negotiator.git"},"homepage":"https://github.com/jshttp/negotiator#readme","bugs":{"url":"https://github.com/jshttp/negotiator/issues"},"license":"MIT","readmeFilename":"README.md"}