npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chubbyts/chubbyts-negotiation

v4.5.1

Published

A simple negotiation library.

Readme

chubbyts-negotiation

CI Coverage Status Mutation testing badge npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A simple negotiation library.

Requirements

Installation

Through NPM as @chubbyts/chubbyts-negotiation.

npm i @chubbyts/chubbyts-negotiation@^4.5.1

Usage

Accept-Language

import { createAcceptLanguageNegotiator } from '@chubbyts/chubbyts-negotiation/dist/accept-language-negotiator';

const negotiator = createAcceptLanguageNegotiator(['en', 'de']);
const value = negotiator.negotiate('de,en;q=0.3,en-US;q=0.7');

Accept

import { createAcceptNegotiator } from '@chubbyts/chubbyts-negotiation/dist/accept-negotiator';

const negotiator = createAcceptNegotiator(['application/json', 'application/xml', 'application/x-yaml']);
const value = negotiator.negotiate('text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q =0.8');

Content-Type

import { createContentTypeNegotiator } from '@chubbyts/chubbyts-negotiation/dist/content-type-negotiator';

const negotiator = createContentTypeNegotiator(['application/json', 'application/xml', 'application/x-yaml']);
const value = negotiator.negotiate('application/xml; charset=UTF-8');

Service factories (chubbyts-dic-config)

The package ships service factories (abstract factories built on chubbyts-dic-config-factory) for a chubbyts-dic-config (or any chubbyts-dic-types compatible) container within @chubbyts/chubbyts-negotiation/dist/service-factory.

Each negotiator reads its supported values from a <negotiator>SupportedValues service if registered, and falls back to a default otherwise:

  • acceptLanguageNegotiatorServiceFactory: acceptLanguageNegotiatorSupportedValues, default []
  • acceptNegotiatorServiceFactory: acceptNegotiatorSupportedValues, default the contentTypes of the encoder service
  • contentTypeNegotiatorServiceFactory: contentTypeNegotiatorSupportedValues, default the contentTypes of the decoder service

The defaults are designed to reuse the type decoders / encoders of chubbyts-decode-encode (or anything else shaped like { contentTypes: Array<string> }), so the negotiators support exactly what can be decoded / encoded:

import type { ConfigFactory } from '@chubbyts/chubbyts-dic-config/dist/dic-config';
import { createContainerByConfigFactory } from '@chubbyts/chubbyts-dic-config/dist/dic-config';
import { decoderServiceFactory, encoderServiceFactory } from '@chubbyts/chubbyts-decode-encode/dist/service-factory';
import type { Negotiator } from '@chubbyts/chubbyts-negotiation/dist/negotiation';
import {
  acceptLanguageNegotiatorServiceFactory,
  acceptNegotiatorServiceFactory,
  contentTypeNegotiatorServiceFactory,
} from '@chubbyts/chubbyts-negotiation/dist/service-factory';

const container = createContainerByConfigFactory({
  dependencies: {
    factories: new Map<string, ConfigFactory>([
      ['decoder', decoderServiceFactory()],
      ['encoder', encoderServiceFactory()],
      ['acceptLanguageNegotiator', acceptLanguageNegotiatorServiceFactory()],
      ['acceptLanguageNegotiatorSupportedValues', (): Array<string> => ['en', 'de']],
      ['acceptNegotiator', acceptNegotiatorServiceFactory()],
      ['contentTypeNegotiator', contentTypeNegotiatorServiceFactory()],
    ]),
  },
})();

const acceptLanguageNegotiator = container.get<Negotiator>('acceptLanguageNegotiator'); // en, de
const acceptNegotiator = container.get<Negotiator>('acceptNegotiator'); // all encoder content types
const contentTypeNegotiator = container.get<Negotiator>('contentTypeNegotiator'); // all decoder content types

To override the supported values, register the related service:

const container = createContainerByConfigFactory({
  dependencies: {
    factories: new Map<string, ConfigFactory>([
      ['acceptNegotiator', acceptNegotiatorServiceFactory()],
      ['acceptNegotiatorSupportedValues', (): Array<string> => ['application/json']],
    ]),
  },
})();

With names

To negotiate different parts of an application with different supported values, the same factories can be registered multiple times with a name, which gets appended to each service id (acceptNegotiatorapi, acceptNegotiatorSupportedValuesapi, encoderapi, ...).

const container = createContainerByConfigFactory({
  dependencies: {
    factories: new Map<string, ConfigFactory>([
      ['decoderapi', decoderServiceFactory('api')],
      ['encoderapi', encoderServiceFactory('api')],
      ['acceptNegotiatorapi', acceptNegotiatorServiceFactory('api')],
      ['contentTypeNegotiatorapi', contentTypeNegotiatorServiceFactory('api')],
      ['acceptNegotiatoradmin', acceptNegotiatorServiceFactory('admin')],
      ['acceptNegotiatorSupportedValuesadmin', (): Array<string> => ['text/html']],
    ]),
  },
})();

const apiAcceptNegotiator = container.get<Negotiator>('acceptNegotiatorapi'); // content types of encoderapi
const adminAcceptNegotiator = container.get<Negotiator>('acceptNegotiatoradmin'); // text/html

Copyright

2026 Dominik Zogg