Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

negotiator

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

negotiator - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

4

lib/negotiator.js

@@ -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'],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc