negotiator
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -24,6 +24,6 @@ module.exports = Negotiator; | ||
Negotiator.prototype[singular] = function() { | ||
var set = this[plural](); | ||
Negotiator.prototype[singular] = function(available) { | ||
var set = this[plural](available); | ||
if (set) return set[0]; | ||
}; | ||
}) |
{ | ||
"name": "negotiator", | ||
"description": "HTTP content negotiation", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"author": "Federico Romero <federico.romero@outboxlabs.com>", | ||
@@ -6,0 +6,0 @@ "contributors": ["Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"], |
@@ -11,15 +11,15 @@ # Negotiator | ||
# The negotiator constructor receives a request object | ||
// The negotiator constructor receives a request object | ||
negotiator = new Negotiator(request) | ||
# Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg';q=0.8 | ||
// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg';q=0.8 | ||
negotiator.preferredMediaTypes() | ||
# -> ['text/html', 'application/*', 'image/jpeg'] | ||
// -> ['text/html', 'application/*', 'image/jpeg'] | ||
negotiator.preferredMediaTypes(availableMediaTypes) | ||
# -> ['text/html', 'application.json'] | ||
// -> ['text/html', 'application.json'] | ||
negotiator.preferredLanguage(availableMediaTypes) | ||
# -> 'text/html' | ||
// -> 'text/html' | ||
@@ -46,12 +46,12 @@ You can check a working example at `examples/accept.js`. | ||
# Let's say Accept-Language header is 'en;q=0.8, es, pt' | ||
// Let's say Accept-Language header is 'en;q=0.8, es, pt' | ||
negotiator.preferredLanguages() | ||
# -> ['es', 'pt', 'en'] | ||
// -> ['es', 'pt', 'en'] | ||
negotiator.preferredLanguages(availableLanguages) | ||
# -> ['es', 'en'] | ||
// -> ['es', 'en'] | ||
language = negotiator.preferredLanguage(availableLanguages) | ||
# -> 'es' | ||
// -> 'es' | ||
@@ -78,12 +78,12 @@ You can check a working example at `examples/language.js`. | ||
# Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2' | ||
// Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2' | ||
negotiator.preferredCharsets() | ||
# -> ['utf-8', 'iso-8859-1', 'utf-7'] | ||
// -> ['utf-8', 'iso-8859-1', 'utf-7'] | ||
negotiator.preferredCharsets(availableCharsets) | ||
# -> ['utf-8', 'iso-8859-1'] | ||
// -> ['utf-8', 'iso-8859-1'] | ||
negotiator.preferredCharset(availableCharsets) | ||
# -> 'utf-8' | ||
// -> 'utf-8' | ||
@@ -110,12 +110,12 @@ You can check a working example at `examples/charset.js`. | ||
# Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5' | ||
// Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5' | ||
negotiator.preferredEncodings() | ||
# -> ['gzip', 'identity', 'compress'] | ||
// -> ['gzip', 'identity', 'compress'] | ||
negotiator.preferredEncodings(availableEncodings) | ||
# -> ['gzip', 'identity'] | ||
// -> ['gzip', 'identity'] | ||
negotiator.preferredEncoding(availableEncodings) | ||
# -> 'gzip' | ||
// -> 'gzip' | ||
@@ -122,0 +122,0 @@ You can check a working example at `examples/encoding.js`. |
@@ -39,2 +39,6 @@ (function() { | ||
}, { | ||
accept: 'deflate', | ||
provided: ['gzip', 'identity'], | ||
selected: ['identity'] | ||
}, { | ||
accept: '*', | ||
@@ -41,0 +45,0 @@ provided: ['identity', 'gzip'], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26496
700
1