@sharadbrat/variator
v0.0.1
Published
Library that provides convenient API for easy AB-testing
Downloads
4
Readme
@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
License
MIT