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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@momsfriendlydevco/vote-tally

v0.0.8

Published

Angular directive to show vote totals - accepted, rejected, abstaining, totals etc.

Downloads

17

Readme

vote-tally

Simple UI widget to show and calculate vote tallies.

Screenshot

Demo

Installation

NOTE: This module requires angular-bs-tooltip.

  1. Grab the NPM
npm install --save @momsfriendlydevco/vote-tally
  1. Install the required script + CSS somewhere in your build chain or include it in a HTML header:
<script src="/libs/vote-tally/dist/votetally.min.js"/>
<link href="/libs/vote-tally/dist/vote-tally.min.css" rel="stylesheet" type="text/css"/>
  1. Include the router in your main angular.module() call:
var app = angular.module('app', ['angular-ui-vote-tally'])
  1. Use somewhere in your template:
<vote-tally total="100" approve="40" reject="20" abstain="10" method="2/3rds" summary="true"></vote-tally>

A demo is also available. To use this follow the instructions in the demo directory.

API

vote-tally exposes two main components: a generic service library which provides a list of voting schemas supported and information on voting methods and the UI component itself.

Within Node the API is accessed as an object:

var voteTally = require('@momsfriendlydevco/vote-tally');

// Calculate 2/3rds majority voting method with 100 people and 10 abstaining
var ratio = voteTally.getWinLose({
	method: '2/3rds',
	total: 100,
	abstain: 10,
});

Within AngularJS this is accessed as a service:

angular
	.module('app')
	.component('myController', {
		controller: function(VoteTally) {
			VoteTally.getWinLose(...);
		},
	});

methods

An array of objects for all supported voting methods. Each item will contain an id as well as a human readable title and a brief description.

getWinLose()

Calculate the ratios for a given voting method given the total number of voters and an optional number of voters abstaining.

// Calculate 2/3rds majority voting method with 100 people and 10 abstaining
var ratio = voteTally.getWinLose({
	method: '2/3rds',
	total: 100,
	abstain: 10,
});

UI Component

The UI widget is a AngularJS component which is declared as:

<vote-tally total="100" approve="30" reject="20" abstain="5" method="simpleMajority" summary="true" tooltips="hover"></vote-tally>

The following options are accepted:

| Option | Type | Default | Description | |------------------|------------|--------------------|-----------------------------------------------------------------------------------------------------------------------| | method | string | "simpleMajority" | The voting method used to calculate the target votes. This can be any ID supported in the methods collection | | total | number | 100 | The total number of voters | | approve | number | 0 | The number of voters who accept the motion | | reject | number | 0 | The number of voters who reject the motion | | abstain | number | 0 | The number of voters who are abstaining | | summary | boolean | false | Whether to show the summary area at the bottom of the widget | | tooltips | string | "hover" | When to display tooltips. Values supported: "never", "hover" (default), "always" | | onClickPass | function | undefined | A function to fire when the user clicks on the X / Y to pass summary pane or the far left progress bar | | onClickReject | function | undefined | A function to fire when the user clicks on the X / Y to reject summary pane or the second to far right progress bar | | onClickAbstain | function | undefined | A function to fire when the user clicks on the X abstaining summary pane or the far right progress bar | | onClickWaiting | function | undefined | A function to fire when the user clicks on the X to vote summary pane or the remaining area of the progress bar |