# experiment-api

> GroupBy Experiment API client

Latest version **1.0.2** (published 2017-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install experiment-api
pnpm add experiment-api
yarn add experiment-api
bun add experiment-api
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-04-06 |
| First published | 2017-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | GroupBy |
| Maintainers | groupby |

## Links

- npm: https://www.npmjs.com/package/experiment-api
- Repository: https://github.com/groupby/experiment-api-javascript
- Homepage: https://github.com/groupby/experiment-api-javascript#readme
- Issues: https://github.com/groupby/experiment-api-javascript/issues
- npm.io page: https://npm.io/package/experiment-api

## Dependencies (1)

- [murmurhash](https://npm.io/package/murmurhash.md) 0.0.2

## Recent versions

- 1.0.2 (latest) — 2017-04-06
- 1.0.1 — 2017-01-17
- 1.0.0 — 2017-01-17

## README

# experiment-api-javascript

[![Greenkeeper badge](https://badges.greenkeeper.io/groupby/experiment-api-javascript.svg)](https://greenkeeper.io/)

## Install

```bash
npm install experiment-api
```

## Use
```javascript
const experimentApi = require('experiment-api');
const Bucketer = experimentApi.bucketer.Bucketer;

const bucketConfiguration = {
  trafficAllocation:       75,
  trafficAllocationOffset: 0,
  bucketPercentages:       [
    25,
    30,
    30,
    15
  ]
};

const bucketer = new Bucketer(bucketConfiguration);
const bucketId = bucketer.getBucketId('some string like visitorId');

switch (bucketId) {
  case -1:
    console.log('No bucket');
    break;
  case 0:
    console.log('First bucket. 25% bucket');
    break;
  case 1:
    console.log('Second bucket. 30% bucket');
    break;
  case 2:
    console.log('Third bucket. 30% bucket');
    break;
  case 3:
    console.log('Forth bucket. 15% bucket');
    break;
  default:
    console.log('Should not happen');
    break
}
```

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