Skip to the content

Taisen Brackets対戦

Knockout brackets as SVG, from a list of ties.

Taisen (対戦, たいせん) is Japanese for a matchup: two sides facing each other. About the name

Contents

Reference · Draw a bracket, a table or a road to the final

tallyMedalsfunction

Adds up a list of medals into the rows of a table, one row for each name, keeping the first flag, mark, code and note given for it. filter keeps only the medals of one sport, one category or one Games (or a list of them): the same list gives the table of an event, of a sport and of all time. Throws a RangeError for a medal that is not gold, silver or bronze or has no name.

Import it

import { tallyMedals } from "@johnmorrisdotca/taisen-brackets";

Definition

function tallyMedals(awards: readonly MedalAward[], filter?: MedalFilter): MedalRow[]

Parameters

NameTypeDescription
awardsreadonly MedalAward[]

The medals won.

filter (optional)MedalFilter

Which medals to count: a sport, a category or a Games.

Returns

MedalRow[]

One row for each name, ready for medalTable.

Examples

import { medalTable, tallyMedals } from "@johnmorrisdotca/taisen-brackets";

const awards = [
  { name: "France", flag: "FR", medal: "gold", sport: "judo", category: "+100 kg", games: 2024 },
  { name: "Japan", flag: "JP", medal: "silver", sport: "judo", category: "+100 kg", games: 2024 },
  { name: "France", medal: "bronze", sport: "judo", category: "-66 kg", games: 2020 },
  { name: "Japan", medal: "gold", sport: "wrestling", category: "-65 kg", games: 2020 },
] as const;
const judo = tallyMedals(awards, { sport: "judo" });
console.log(judo.map((r) => `${r.name} ${r.gold}-${r.silver}-${r.bronze}`).join(", "), medalTable({ rows: judo }).includes("France"));
France 1-0-1, Japan 0-1-0 true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/taisen-brackets 0.20.0.