Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 15, 2024 via pnpm
Package summary
Share
0
issues
1
license
1
MIT
Package created
26 Jan 2012
Version published
23 Jan 2022
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
negotiator@0.6.3
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of negotiator 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does negotiator do?

Negotiator is an HTTP content negotiation module for Node.js. It aids your applications by simplifying the negotiation process between the server and client for specific content types, languages, charsets, and encodings that are based on HTTP headers.

How do you use negotiator?

To use Negotiator in your Node.js application, start by installing the negotiator package via npm using the command npm install negotiator. Once installed, you can import Negotiator into your project using var Negotiator = require('negotiator').

Here's an example of how Negotiator can be used for media negotiation:

var Negotiator = require('negotiator');
var availableMediaTypes = ['text/html', 'text/plain', 'application/json'];
var negotiator = new Negotiator(request);
var preferredMediaType = negotiator.mediaType(availableMediaTypes);

In the above case, the preferred media type is determined based on the client's Accept header. The available media types are listed in the server, and the most preferred one is returned by the negotiator.mediaType(availableMediaTypes) method.

The same method applies to the Accept-Language, Accept-Charset, and Accept-Encoding negotiations. You just need to use the appropriate methods such as negotiator.languages(availableLanguages), negotiator.charsets(availableCharsets), or negotiator.encodings(availableEncodings).

Where are the negotiator docs?

The documentation for the Negotiator module can be found in the readme file on the Github repository for the package, which is accessible at the following URL: https://github.com/jshttp/negotiator. The readme contains all needed information on how to install and utilize Negotiator in your Node.js project. It also provides details on the different methods available and illustrated examples of how to implement content negotiations using the module.