Package Exports
- accept-language
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (accept-language) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
accept-language-parser
Parses the accept-language header from an HTTP request and produces an array of language objects sorted by quality.
dependencies: none
installation:
npm install accept-language-parser
usage:
var parser = require('accept-language-parser');
var language = parser.parse('en-GB,en;q=0.8');
console.log(language);
Output will be:
[
{
code: "en",
region: "GB",
quality: 1.0
},
{
code: "en",
region: undefined,
quality: 0.8
}
];
Output is always sorted in quality order from highest -> lowest. as per the http spec, omitting the quality value implies 1.0.
Known issues
- Cannot cope with multi-part region codes, i.e. 'az-AZ-Cyrl' will be treated as 'az-AZ'
Running tests
npm install
grunt test