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

ab-test-service

v0.0.1

Published

An AngularJS service for creating imperative A/B/n tests in your AngularJS projects.

Downloads

4

Readme

ab-test-service NPM version Build Status Coveralls Status Dependency Status

An AngularJS service for creating imperative A/B/n tests in your AngularJS projects. This service makes no assumptions about how your application is set up or how you want to use it. While for most applications a single A/B test service created at config time will be all you need. There's no reason you can't lazily create the A/B test service, or have multiple instances.

Install Choices

Setup

  1. Include the ab-svc.js script provided by this component into your app.
  2. Add ab.test.service as a module dependency to your app.

Usage

This module exposes a abMfg (factory), which is an API for instantiating A/B tests that are integrated with Angular's digest cycle.

Making an A/B Test Service Instance

// create module with ab.test.service dependency
var demo = angular.module('demo', ['ab.test.service']);

// create a/b test service instance
demo.factory('ab', function(abMfg) {
  return abMfg();
});

With that, you can inject your ab service into controllers and other services anywhere in your application!

Using Your A/B Test Service Instance

Building on the example above (see demo for full context):

// use ab test service in a controller
demo.controller('abTestCtrl', ['$scope', 'ab', function($scope, ab) {
  // look up the button element
  var btn = document.getElementById('example');

  // run a/b test to select css class name
  var cssClass = ab.test(['default','primary','success','info','warning','danger','link'], 1);

  // update the ui
  btn.className = 'btn btn-lg btn-' + cssClass;

  // log variant shown (example)
  //AB.log({shown:cssClass}, "http://www.example.com/log");

  // provide a go button to the repo
  $scope.go = function () {
    // log variant chosen & use optional callback to ensure the page is not left before log completes
    AB.log({chose:cssClass}, "http://www.example.com/log", function(e) {

      // example of checking the event type
      if (e.type === "error") {
        // unable to log a/b test results :(
      } else {
        // a/b test results logged! :)
      }

      // continue to the repo
      location = 'https://github.com/daniellmb/ab-test-service';
    });
  }
}]);

The API

See ab.js documentation for the latest

The ab.js library consists of two parts the A/B tester (ab.js) and the logger (log.js). These are separate to enable you to choose the best tools based on your environment. Say for example you already have jQuery on the page and want to use that for logging data, great, then all you need to include is ab.js.

Testing

Run npm install to make sure you have all the development dependencies. Run npm test to make run all the unit tests. If you make changes to ab-svc.js file: Run npm run gulp to update the .min.js and .map files.

License

(The MIT License)

Copyright (c) 2014 Daniel Lamb <daniellmb.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.