# dice-roll

> A JavaScript A/B test library

Latest version **2.1.0** (published 2019-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install dice-roll
pnpm add dice-roll
yarn add dice-roll
bun add dice-roll
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2019-07-03 |
| First published | 2011-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | First+Third |
| Maintainers | alaguna, aleperez92, dawnerd, ecwillis, jga, orthagonal1 |
| Keywords | dice-roll, conversion |

## Links

- npm: https://www.npmjs.com/package/dice-roll
- Repository: https://github.com/firstandthird/dice-roll
- Homepage: https://github.com/firstandthird/dice-roll#readme
- Issues: https://github.com/firstandthird/dice-roll/issues
- npm.io page: https://npm.io/package/dice-roll

## Dependencies (1)

- [@firstandthird/cookie-monster](https://npm.io/package/@firstandthird/cookie-monster.md) ^3.1.0

## Recent versions

- 2.1.0 (latest) — 2019-07-03
- 2.0.0 — 2019-04-12
- 1.0.0 — 2017-04-26
- 0.0.4 — 2012-01-26
- 0.0.2 — 2011-10-14
- 0.0.1 — 2011-10-14

## README

# Dice Roll

[![Build Status](https://travis-ci.org/firstandthird/dice-roll.svg?branch=master)](https://travis-ci.org/firstandthird/dice-roll)
![npm](https://img.shields.io/npm/v/dice-roll.svg)

A simple A/B test library for JavaScript

## Features

- Pass in any percentage to test
- Will cookie user so they stay in the test when they come back (requires: [cookie-monster](https://github.com/firstandthird/cookie-monster))
- Get a callback that tells you whether the user is in the test or not

## Installation

```sh
npm install dice-roll
```

## Usage

```js
  diceRoll('testName', expiration) //jquery style chaining
    .test(percentage, callback);
    .test(percentage2, callback2);
    .otherwise(callback3);
    .run();
```

## Example

```js
  diceRoll('testName', 1) //cookied for 1 day
    .test(10, function() {
      //10% of the time user will be in this test
    });
    .test(20, function() {
      //20% of the time user will be in this test
    });
    .otherwise(function() {
      //called if not in either other test (70% of the time)
    });
    .run();
```

---
_Source: https://npm.io/package/dice-roll · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
