Socket
Socket
Sign inDemoInstall

encoding-negotiator

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    encoding-negotiator

a negotiator for the accept-encoding header


Version published
Weekly downloads
100K
increased by4.24%
Maintainers
1
Install size
6.25 kB
Created
Weekly downloads
 

Readme

Source

encoding-negotiator

Install

Build Status Coverage Status NPM version JavaScript Style Guide Greenkeeper badge

npm install encoding-negotiator

Example

const encodingNegotiator = require('encoding-negotiator');

encodingNegotiator.negotiate({
  header: 'compress;q=0.5, gzip;q=1.0',
  supportedEncodings: ['gzip', 'deflate', 'identity']
); //returns gzip

API

negotiate(header, supported)

Returns the most preffered encoding available in supportedEncodings The first element of the supportedEncodings array will be used in case of an asterisk.

header

The accept-encoding header.

supportedEncodings

An array of the supported encodings.

prefferedEncoding (optional)

An encoding preffered by the server if the client sends multiple encodings no quality value (for example Accept-Encoding: gzip, deflate, br).

Benchmark

$ node benchmark/benchmark.js 
negotiator x 260,201 ops/sec ±0.64% (88 runs sampled)
encoding-negotiator x 434,196 ops/sec ±1.23% (88 runs sampled)
Fastest is encoding-negotiator

License

MIT

Keywords

FAQs

Last updated on 23 Feb 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc