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

groupstage-tb

v1.3.1

Published

GroupStage tourney that tiebreaks until all done

Downloads

20

Readme

GroupStage-Tb

npm status build status dependency status coverage status

This module wraps GroupStage and TieBreaker in such a way that TieBreaker is invoked with as many rounds as is necessary to resolve ties (typically zero or one time). It is an implementation of tourney.

If you want to pick an exact number of players from a GroupStage to advance to a second stage in a Tourney this module (or something like it) is required. GroupStage does not provide much in way of resolving ties except from with the statistics it works out internally, but if the number of points and the sum of map scores (.for and .against) are all identical it needs help to break up for the next stage.

Usage

Use like GroupStage, but set a limit:

var GS = require('groupstage-tb');
var trn = new GS(6, { groupSize: 3, limit: 4 }); // want top 4 to proceed

// matches are equivalent to a normal GroupStage instance
trn.matches;
[ { id: Id { s: 1, r: 1, m: 1 }, p: [ 3, 6 ] },
  { id: Id { s: 1, r: 2, m: 1 }, p: [ 1, 6 ] },
  { id: Id { s: 1, r: 3, m: 1 }, p: [ 1, 3 ] },
  { id: Id { s: 2, r: 1, m: 1 }, p: [ 4, 5 ] },
  { id: Id { s: 2, r: 2, m: 1 }, p: [ 2, 5 ] },
  { id: Id { s: 2, r: 3, m: 1 }, p: [ 2, 4 ] } ]

// score it with ties
trn.matches.forEach(m => {
  if (m.id.s === 2) {
    trn.score(m.id, [1,1]); // tie group 2 completely
  }
  else {
    trn.score(m.id, m.p[0] < m.p[1] ? [1,0]: [0,1]); // everywhere else scored in seed order
  }
});

trn.stageDone(); // true
trn.isDone(); // false (cannot determine top 4 when one group is tied)
trn.createNextStage(); // true (forced to create another stage)

// new set of matches is the subset of matches needed to be played to break
// in this case we have to break an entire group, so it's a replay
trn.matches;
[ { id: Id { s: 2, r: 1, m: 1 }, p: [ 4, 5 ] },
  { id: Id { s: 2, r: 2, m: 1 }, p: [ 2, 5 ] },
  { id: Id { s: 2, r: 3, m: 1 }, p: [ 2, 4 ] } ]

trn.matches.forEach(m => {
  trn.score(m.id, m.p[0] < m.p[1] ? [1,0]: [0,1]); // score by seed
});

trn.stageDone(); // true - tiebreaker round over
trn.isDone(); // true - no further tiebreaking needed
trn.complete(); // can lock it down when isDone()

// Since we scored all matches by seeds (ultimately) - top 4 can be chosen unambiguously
trn.results().slice(0,4).map(r => r.seed);
[ 1, 2, 3, 4 ]

This module is here pretty much only here for the last step. If you tried this slice when just using GroupStage you could get 3 players from group one and 1 player from group two in the absence of sufficient information to split them up between groups. Tournament.from relies on the results().slice to select the people to pass through so this infomation must be as accurate as possible.

Combination

Since this module is a Tourney, you can use it in other tourneys.

The canonical groupstage to duel tournament implementation, groupstage-tb-duel uses this module as the "first stage" (even though it can be more than one stage when tiebreaking kicks in), then pipes the winners to a duel Tournament - for almost all use cases, this is likely what you want.

If you have less conventional ideas about tournament structure, you could plumb this module into other things. The modularity is there.

Installation

From npm:

$ npm install groupstage-tb

License

MIT-Licensed. See LICENSE file for details.