proctorjs
v1.0.0
Published
A simple library for using proctor in JavaScript.
Downloads
3
Readme
ProctorJS
A simple library for using Proctor results in JavaScript. This library can be used both in the browser or on a NodeJS server like express or restify.
Installation
NodeJS
npm install proctorjs --save
Bower
bower install proctorjs --save
Usage
NodeJS
var Proctor = require('proctorjs').Proctor;
Browser
<head>
...
<script src=".../bower_components/proctorjs/src/proctor.js"></script>
</head>
API
The utility has a fairly simple API. Once the utility has been initialized, it can be queried for any test group. Below is an example as to how this utility can be used.
Proctor.init({'test1', 0});
Proctor.inGroup('test1', 0); // TRUE
Proctor.inGroup('test1', 1); // FALSE
Proctor.inGroup('test2', 1); // FALSE
Proctor.init(Object.<string, number>)
This method initializes the utility with the test groups from proctor.
Proctor.getGroups(): Object.<string, number>
Returns the groups that the utility is currently configured with.
Proctor.inGroup(string, number): boolean
Return whether or not the current user falls into the desired test group.
Proctor.getGroupValue(string): number
Gets the value for the desired test group. If the the test group does not exist, then -1 is returned.