New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-ab-decider

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ab-decider

[![CircleCI](https://circleci.com/gh/zapaiamarce/node-ab-decider.svg?style=svg)](https://circleci.com/gh/zapaiamarce/node-ab-decider)

  • 0.0.20
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

CircleCI

Setup

npm install node-ab-decider

Use

const decider = require('node-ab-decider')
const choosen = "oldVariant"
const experiments = {
  variantA: {
    weight: 10,
    url: "https://exp-a.example.com/"
  },
  variantB: {
    weight: 20,
    url: "https://exp-b.example.com/"
  }
}
const x = decider(experiments, choosen)
// possible "x" value: {weight: 10, name:"variantA", url: "https://exp-a.example.com/"}

NOTE: If choosen is present the experiments object it doesn't run the choosing algorithm. If it's not present it re-run the process.

With Express

var app = require('express')();
const {middleware} = require('node-ab-decider')

const experiments = {
  variantA: {
    weight: 10,
    url: "https://exp-a.example.com/"
  },
  variantB: {
    weight: 20,
    url: "https://exp-b.example.com/"
  }
}

app.use(middleware(experiments, {
  // ...opts
}), (req,res)=>res.send('original'))

app.listen(2323,()=>console.log('running on 2323'))

Same logic but, it uses cookies to get the choosen or set the cookie.

Middleware options

maxAge

Expiration (in milliseconds) of the cookie

cookieName

Name of the cookie used to save the choosen exp

skip

Skip this middleware. Useful in dev mode.

hash

Hash added to the cookie. It is something like a version.

sendHeaderToChild

If false it avoids to send "ab-decider-child" header to the proxied endpoint

https

Force https to children

headers

Headers to include in every response

FAQs

Package last updated on 07 Jun 2019

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