-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
55 lines (55 loc) · 5.37 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
"name": "negotiator",
"description": "HTTP content negotiation",
"version": "0.4.9",
"author": {
"name": "Federico Romero",
"email": "federico.romero@outboxlabs.com"
},
"contributors": [
{
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
}
],
"repository": {
"type": "git",
"url": "git+https://github.com/jshttp/negotiator.git"
},
"keywords": [
"http",
"content negotiation",
"accept",
"accept-language",
"accept-encoding",
"accept-charset"
],
"license": "MIT",
"devDependencies": {
"istanbul": "~0.3.2",
"nodeunit": "0.8.x"
},
"scripts": {
"test": "nodeunit test",
"test-cov": "istanbul cover ./node_modules/nodeunit/bin/nodeunit test"
},
"engines": {
"node": ">= 0.6"
},
"main": "lib/negotiator.js",
"files": [
"lib",
"LICENSE"
],
"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][travis-image]][travis-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##### mediaTypes(availableMediaTypes):\n\nReturns an array of preferred media types ordered by priority from a list of available media types.\n\n##### mediaType(availableMediaType):\n\nReturns the top preferred media type from a list of available 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##### languages(availableLanguages):\n\nReturns an array of preferred languages ordered by priority from a list of available languages.\n\n##### language(availableLanguages):\n\nReturns the top preferred language from a list of available 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##### charsets(availableCharsets):\n\nReturns an array of preferred charsets ordered by priority from a list of available charsets.\n\n##### charset(availableCharsets):\n\nReturns the top preferred charset from a list of available 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##### encodings(availableEncodings):\n\nReturns an array of preferred encodings ordered by priority from a list of available encodings.\n\n##### encoding(availableEncodings):\n\nReturns the top preferred encoding from a list of available encodings.\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/negotiator.svg?style=flat\n[npm-url]: https://npmjs.org/package/negotiator\n[node-version-image]: https://img.shields.io/node/v/negotiator.svg?style=flat\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/negotiator.svg?style=flat\n[travis-url]: https://travis-ci.org/jshttp/negotiator\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/negotiator.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/jshttp/negotiator?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/negotiator.svg?style=flat\n[downloads-url]: https://npmjs.org/package/negotiator\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/jshttp/negotiator/issues"
},
"homepage": "https://github.com/jshttp/negotiator#readme",
"_id": "negotiator@0.4.9",
"_shasum": "92e46b6db53c7e421ed64a2bc94f08be7630df3f",
"_resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.4.9.tgz",
"_from": "https://registry.npmjs.org/negotiator/-/negotiator-0.4.9.tgz"
}