Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ab_test_selecting

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ab_test_selecting

Select an option from the list, particularly a/b test. Use only Math.random is wrong because the function is nondeterministic

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ab_test_selecting

Select an option from the list, particularly a/b test. Use only Math.random is wrong because the function is nondeterministic

You can see distribution and you may be modify him

Getting Started

Installing

 npm install ab_test_selecting@latest -S

Examples

  const AbTestSelecting = require('ab_test_selecting.js');
  // load settings
  const abTestSelecting = new AbTestSelecting({
    page_something: {
      variations: [{
        name: "first",
        ratio: 25, // required
        visited: 0, // required, maybe not zero
      }, {
        name: "two",
        ratio: 60, // required
        visited: 0, // required, maybe not zero
      },  {
        name: "three",
        ratio: 15, // required
        visited: 0, // required, maybe not zero
      }]
    }
  });

  var page, variant;
  for (var i = 0; i < 274; i++) {
    var res = abTestSelecting.choice('page_something');
    if (res instanceof Error) {
      throw res;
    }
    ({ page, variant } = res);
  }
  // {
  //   variations: [{
  //     name: 'first',
  //     ratio: 25,
  //     visited: 68
  //   }, {
  //     name: 'two',
  //     ratio: 60,
  //     visited: 163
  //   }, {
  //     name: 'three',
  //     ratio: 15,
  //     visited: 43
  //   }]
  // }
  console.log(page);
  // { name: 'two', ratio: 60, visited: 163 }
  console.log(variant);

Running the tests

 npm run test

Keywords

FAQs

Package last updated on 18 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc