npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-feature

v1.0.2

Published

Simple Feature API enabling rampups and A/B testing.

Downloads

14

Readme

Feature

Build Status Latest Stable Version Total Downloads License

Feature is a rampup and AB testing library for Node. It is a port of our Laravel library and has a very similar functionality.

How to use

var Feature = require('node-feature');

var featureConfiguration = {
    featureA: {
        variantA: 10,
        variantB: 10,
        variantC: 80
    },
    featureB: [
        'variantA',
        'variantB'
    ],
    featureC: 50
};

var features = Feature(featureConfiguration, sessionHash, overrides);

At this point features object will consist of all defined features and their selected variants.

{
    featureA: 'variantC',
    featureB: 'variantA',
    featureC: null,
}

Feature Configuration

Each feature can have any number of variants with each variant defining its own odds.

{
    feature: {
        variantA: 25,
        variantB: 25,
        variantC: 50
    }
}

In the above example, each variant has the specified chance of being selected. Variants with odds below 0 are normalized to 0. The variants are processed top to bottom. If the sum of odds exceeds 100 the feature is saturated and any variants above that threshold have no chance of being selected.

{
    feature: {
        variantA: 100,
        variantB: 25,
        variantC: 50
    }
}

The above feature will always return variantA.

You can omit the odds and just specify the variants. In this case, the variants are evenly spread out.

{
    feature: [
        'variant_a',
        'variant_b'
    ]
}

In this case, both variants have 50% chance of being selected.

To specify a simple ON/OFF feature we just include a single variant.

{
    feature: {
        enabled: 100
    }
}

This feature is always on. We can adjust the odds to turn it off completely or achieve a ramp-up functionality.

It is also possible to shorten the above example by just defining the odds for the feature itself.

{
    feature: 50
}

This feature will be on for 50% of the users.

Session Hash

The second argument identifies the session. It is used to determine the selected variants.

Overrides

The third argument allows for visitors to override the variants. This is used during testing. It's a good idea to restrict this only to specific users.

This can be either a JSON object or a JSON string that specifies the feature and its variant.

{
    featureA: 'variantB',
}

This will force the FeatureA to use VariantB.

You can also pass a comma separated list of features and variants.

featureA:variantA,featureB:variantA

This will force featureA and featureB to both return variantA.