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

@fastify/accept-negotiator

Package Overview
Dependencies
Maintainers
18
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/accept-negotiator

a negotiator for the accept-headers

  • 2.0.0
  • next
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
433K
decreased by-51.05%
Maintainers
18
Weekly downloads
 
Created
Source

@fastify/accept-negotiator

CI NPM version js-standard-style

A negotiator for the accept-headers

Install

npm i @fastify/accept-negotiator

Usage

The module exports a function that you can use for negotiating an accept-header, e.g. accept-encoding. It takes 2 parameters:

negotiate(header, supportedValues)
  • header (string, required) - The accept-header, e.g. accept-encoding
  • supportedValues (string[], required) - The values, which are supported
const negotiate = require('@fastify/accept-negotiator').negotiate
const encoding = negotiate('gzip, deflate, br', ['br'])
console.log(encoding) // 'br*

The module also exports a class that you can use for negotiating an accept-header, e.g. accept-encoding, and use caching for better performance.

Negotiate(supportedValues)
  • supportedValues (string[], required) - The values, which are supported
  • cache ({ set: Function; get: Function; has: Function }, optional) - A Cache-Store, e.g. ES6-Map or mnemonist LRUCache
const Negotiator = require('@fastify/accept-negotiator').Negotiator
const encodingNegotiator = new Negotiator({ supportedValues: ['br'], cache: new Map() })

const encoding = encodingNegotiator.negotiate('gzip, deflate, br')
console.log(encoding) // 'br*

License

Licensed under MIT.

Keywords

FAQs

Package last updated on 03 Sep 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc