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

confidence.js

v0.0.0

Published

Confidence.js is a light-weight JavaScript library to help you make sense of your A/B test results.

Readme

Confidence

Confidence.js is a light-weight JavaScript library to help you make sense of your A/B test results.

Getting started

Download confidence.js

Include confidence.js on your page.

<script src="path/to/confidence.js"></script>

Usage

Initialization

var myConfidence = new Confidence();

Confidence helps you compare the variants in your A/B test. Variants in Confidence.js look like this:

variant = {
	id: 'A',                // short identifier
	name: 'Variant A',      // descriptive identifier
	conversionCount: 50,    // number of events that successfully converted
	eventCount: 300         // total number of events tracked
}

addVariant(variant)

Adds a variant to your A/B test. You can add and compare as many variants as you'd like.

Parameters:

  • variant: the variant object you'd like to add to this A/B test
// first, create some variants
variantA = {
	id: 'A',
	name: 'Alluring Alligators',
	conversionCount: 1500,
	eventCount: 3000
}

variantB = {
	id: 'B',
	name: 'Belligerent Bumblebees',
	conversionCount: 2500,
	eventCount: 3000
}

// then add the variants to your A/B test
myConfidence.addVariant(variantA);
myConfidence.addVariant(variantB);

getResult()

Evaluates the variants in your A/B test and determines which is the winning variant, if there is one.

Returns an object containing:

  • hasWinner: true if a winner could be calculated, false otherwise
  • hasEnoughData: true if there is enough data to calculate a statistically significant result, false otherwise
  • winnerID: the ID of the winning variant, or null if there isn't one
  • winnerName: the name of the winning variant or null if there isn't one
  • confidenceInterval: the confidence interval, or null if there is no winner.
  • ex: { min: 0.154, max: 0.187 }
  • readable: human readable result.
  • ex: There is not enough data to determine a winner.

Examples

Case 1: There is not enough data to determine a result.

// create some variants
variantC = {
	id: 'C',
	name: 'Cranky Capybaras',
	conversionCount: 5,
	eventCount: 50
};

variantD = {
	id: 'D',
	name: 'Diligent Ducklings',
	conversionCount: 60,
	eventCount: 200
};

variantE = {
	id: 'E',
	name: 'Effervescent Elephants',
	conversionCount: 30,
	eventCount: 40
};


// add the variants to your A/B test
myConfidence.addVariant(variantC);
myConfidence.addVariant(variantD);
myConfidence.addVariant(variantE);


// evaluate the variants to get the result
result = myConfidence.getResult();

/*
{
	hasWinner: false,
	hasEnoughData: false,
	winnerID: null,
	winnerName: null,
	confidenceInterval: null,
	readable: 'There is not enough data to determine
		a conclusive result.'
}
*/

Case 2: There is enough data, but there is no clear winner.

// create some variants
variantF = {
	id: 'F',
	name: 'Freaky Flamingos',
	conversionCount: 1501,
	eventCount: 3000
};

variantG = {
	id: 'G',
	name: 'Gregarious Gorillas',
	conversionCount: 1500,
	eventCount: 3000
};

// add the variants to your A/B test
myConfidence.addVariant(variantF);
myConfidence.addVariant(variantG);

// evaluate the variants to get the result
result = myConfidence.getResult();

/*
{
	hasWinner: false,
	hasEnoughData: true,
	winnerID: null,
	winnerName: null,
	confidenceInterval: null,
	readable: 'We have enough data to say we cannot
		predict a winner with 95% certainty.'
}
*/

Case 3: There is enough data and there is a clear winner.

// create some variants
variantH = {
	id: 'H',
	name: 'Hungry Hippopotami',
	conversionCount: 2500,
	eventCount: 3000
};

variantI = {
	id: 'I',
	name: 'Irritable Iguanas',
	conversionCount: 1500,
	eventCount: 3000
};

// add the variants to your A/B test
myConfidence.addVariant(variantH);
myConfidence.addVariant(variantI);

// evaluate the variants to get the result
result = myConfidence.getResult();

/*
{
	hasWinner: true,
	hasEnoughData: true,
	winnerID: 'H',
	winnerName: 'Hungry Hippopotami',
	confidenceInterval: { min: 82, max: 84.67 },
	readable: 'In a hypothetical experiment that
		is repeated infinite times, the average
		rate of the "Hungry Hippopotami" variant
		will fall between 82% and 84.67%, 95%
		of the time'
}
*/

Run Tests

npm install
npm test

TODO

  • Variant name parameter optional
  • requires changes to addVariant, and errors.js
  • add "not provided" default name if left blank
  • add removeVariant function
  • zscore table lookup to provide more accurate results if 95% confidence is not available

Issues and Questions

Found a bug? Create an issue here on GitHub!

For general questions, tweet me @jessicaraygun.

Author

Developed and maintained by Jessica Thomas, Data Scientist @ sendwithus.com