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

killswitch

v0.0.8

Published

Simple utility to help roll in new site features while providing a quick backout 'kill' switch

Downloads

2

Readme

killswitch

Simple utility to help roll in new website features while providing a clearly defined backout "killswitch" mechanism.

Installation

After install node:

$ npm install killswitch

Usage

First create a json file that will define each of the killswitches in an application.

  {
    "newFeatureOne":{
      "enabled":true,
      "description":"Killswitch to control toggle between existing implementation and new Updated version",
      "targets":["feature-module", "another-module"],
      "startDate":"Jan 15, 2015",
      "endDate":"Feb 15, 2015"
      },
      "useSpriteImages":{
        "enabled":false,
        "description":"Implementation of sprites for thumbnails",
        "targets":["npm-thumbs"],
        "startDate":"Dec 1, 2014",
        "endDate":"Mar 10, 2015"
      }
  }

Each killswitch definition must have the following required properties enabled,description, targets as an array, startDate, endDate and the following option properties enabledValue and disabledValue. These optional values will be returned via the method getValue(key, info), this method will default to boolean true/false if either enabledValue and disabledValue are missing.

Next, consume in feature module and create condition check:

//in feature-module.js
var Killswitch = require("killswitch"),
    info = require("../package.json"),
    ks = new Killswitch();
module.exports.getJSON = function(){
  var oldFeatureData = { name:"John Doe", age:30, address:"100 Pine Street"};
  var newFeatureData = { name:"Jane Doe", age:30, address"100 Pine Street", layoutType:"basic", url:"www.thedoes.com", familyHistory:"coming soon"}
  
  //notice this killswitch 'newFeatureOne' does not have enabledValue or disabledValue
  //will default to true if enabled or false if disabled
  return ks.getBoolean("newFeatureOne", info) ? newFeatureData : oldFeatureData;

Alternatively if we did include an enabledValue/disabledValue we could have done something like:

"newFeatureOne":{
      "enabled":true,
      "description":"Killswitch to control toggle between existing implementation and new Updated version",
      "targets":["feature-module", "another-module"],
      "startDate":"Jan 15, 2015",
      "endDate":"Feb 15, 2015",
      "enabledValue":"newFeature",
      "disabledValue":"oldFeature"
}

and returned as:

  var obj = {};
  obj[ks.getValue("newFeatureOne", info)] = ks.getBoolean("newFeatureOne", info) ? newFeatureData : oldFeatureData;
  return obj;

Would produce:

{
  newFeature: { name:"Jane Doe", age:30, address"100 Pine Street", layoutType:"basic", url:"www.thedoes.com", familyHistory:"coming soon"}
}

Which would simplify our handlebars template changes to:

<div>
    {{#if newFeature}}
      {{> myNewPartial newFeature}}
    {{otherwise}}
      {{> currentPartial oldFeature}} 
    {{/if}}
</div>