Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/firstandthird/dice-roll
A javascript a/b test library
https://github.com/firstandthird/dice-roll
Last synced: 14 days ago
JSON representation
A javascript a/b test library
- Host: GitHub
- URL: https://github.com/firstandthird/dice-roll
- Owner: firstandthird
- License: mit
- Created: 2011-10-14T17:53:51.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T21:54:16.000Z (about 2 years ago)
- Last Synced: 2025-01-12T10:13:03.816Z (21 days ago)
- Language: JavaScript
- Homepage:
- Size: 1.32 MB
- Stars: 15
- Watchers: 3
- Forks: 7
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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();
```