Formats
Every function that builds a stage, with its parameters, options and errors.
Every format takes participants in seed order, so the first one is the top seed. Ids must be unique. Each returns a new Stage with byes already resolved.
singleElimination
function singleElimination(participants: Participant[], options?: SingleEliminationOptions): StageA knockout bracket. Any number of participants works: when the field isn't a power of two, the top seeds get byes.
Prop
Type
Prop
Type
Throws a RangeError with fewer than two participants, and an Error when ids repeat.
singleElimination(teams, {
thirdPlace: true,
roundName: (index, total) => (index === total - 1 ? 'Championship' : `Round ${index + 1}`),
});doubleElimination
function doubleElimination(participants: Participant[], options?: DoubleEliminationOptions): StageA winners bracket, a losers bracket fed by its losers, and a grand final. Produces groups {id}.wb, {id}.lb and, unless grandFinal is 'none', {id}.gf.
Prop
Type
Prop
Type
grandFinal | Behaviour |
|---|---|
'reset' | If the losers bracket champion wins the final, a second final ({id}.gf.r2.m1) decides it. Otherwise it's skipped. |
'single' | One final, whatever happens. |
'none' | No grand final. |
roundRobin
function roundRobin(participants: Participant[], options?: RoundRobinOptions): StageEveryone in a group plays everyone else, once per leg. Groups are {id}.g1, {id}.g2…, of kind pool.
Prop
Type
Prop
Type
With groups: 2 and eight participants, snake seeding puts seeds 1, 4, 5 and 8 in group A and 2, 3, 6 and 7 in group B.
swiss
function swiss(participants: Participant[], options?: SwissOptions): Stage
function nextSwissRound(stage: Stage): Stage
function swissRoundsLeft(stage: Stage): numberswiss creates the stage with round one paired. Call nextSwissRound after every match of the current round has a result.
Prop
Type
Prop
Type
nextSwissRound throws when the current round has unfinished matches, or when every round has been played. Check swissRoundsLeft(stage) > 0 first.
fromRounds
function fromRounds(rounds: RoundInput[], options?: FromRoundsOptions): StageBuilds a stage from data you already have. Rounds that halve in size are linked as a knockout tree and equal-sized rounds one to one. See Your own data.
RoundInput
Prop
Type
MatchInput
Prop
Type
ParticipantInput
Prop
Type
FromRoundsOptions
Prop
Type