Need private packages and team management tools?Check out npm Teams »

@sharadbrat/variator

0.0.1 • Public • Published

@sharadbrat/variator

Tiny javascript library that provides simple API for AB and variation testing.

Start

Install dependency:

npm install @sharadbrat/variator

Import in project:

import Variator from '@sharadbrat/variator';

Use:

const v = new Variator();
 
v.set({
  featureA: true,
  featureB: false,
});
 
v.runTest('featureA', () => {
  // do ab testing
});
 
v.runTest('featureB', () => {
  // don't do ab testing
})

Examples

Set function merges provided objects:

const v = new Variator();
 
v.set({
  featureA: true,
  featureB: true,
});
 
v.set({
  featureB: false, // { featureA: true, featureB: false }
});

Clean inner state:

const v = new Variator();
 
v.set({
  featureA: true,
});
 
v.clear(); // sets to empty object

Weighted variations for certain features:

const v = new Variator();
 
v.set({
  featureC: true,
});
 
v.runWeightedTest('featureC', [[1, 'A'], [1, 'B']], (variationName) => {
  // do ab testing with randomly chosen variation
  // variationName is either 'A' or 'B'
});

Testing

npm run test

Runs tests with mocha.

Authors

sharadbrat

License

MIT

Install

npm i @sharadbrat/variator

DownloadsWeekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

8.1 kB

Total Files

6

Last publish

Collaborators

  • avatar