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

bracket-generator

v3.1.1

Published

Generate a tournament bracket.

Downloads

54

Readme

bracket-generator

Generate a tournament bracket.

NPM Build Status Greenkeeper badge

What is this?

bracket-generator, well, it generates brackets! (Check out bracket-data for more info about brackets and their data.)

More specifically, this module generates a string representation of a bracket. That string can then be used with a whole bunch of others modules to validate it, update it, or score it.

This module isn't that useful for selecting brackets (unless you wanted to stage an epic robot bracket challenge, wait, that'd be awesome) but it is useful for testing other bracket modules and creating random (or not-so-random) brackets.

API / Usage

Make a new bracket-generator object with an options object (the year and sport options are required and passed directly to bracket-data):

var BracketGenerator = require('bracket-generator');
var generator = new BracketGenerator({
   year: '2013',
   sport: 'ncaam',
   winners: 'random'
});
console.log(generator.generate());

options

  • sport: The sport you are generating. See bracket-data for more info.
  • year: The year you are generating. See bracket-data for more info.
  • winners: (String, default: 'random') How the winners of the bracket should be selected. See below for the explantion of each option:

winners

The winners option can be a few things:

  • random: it will generate a random bracket! (it probably won't win any office pools)
  • higher: all higher seeds will win. If two seeds are the same, the seed on the bottom of the matchup will win (definitely wont win any office pools)
  • lower: all lower seeds will win. If two seeds are the same, the seed on the top of the matchup will win
  • A binary string (10101110...). The string you pass in should have a length matching the number of games in the bracket. This will generate a bracket with each matchup corresponding to a single character in the string. If the character is 0 the lower seed will win. If the character is 1 the higher seed will win. This is useful because it allows you to create every possible bracket! See the tests for how I accomplished that.

methods

  • generate(winners): Generate the bracket. The param winners is optional here. If you pass it in, it will reset the generator first and then generate a bracket using the winners option you passed in, otherwise it will use the option it was instantiated with. It will a bracket string.

License

MIT