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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-table-standings

v2.0.1

Published

Simple Table Standings Calculation

Readme

Simple Table Standings

npm version License: ISC TypeScript

A lightweight TypeScript library for calculating sports standings tables with head-to-head records.

Features

  • 🎯 Accurate points calculation
  • 🔄 Head-to-head records
  • 📊 Goal difference tracking
  • 💪 TypeScript support
  • 0️⃣ Zero dependencies

Installation

npm install simple-table-standings
# or
yarn add simple-table-standings
# or
pnpm add simple-table-standings

Usage

import simpleTableStandings from "simple-table-standings";

const teamsMatches = [
  {
    name: "Hajduk",
    matches: {
      dinamo: [
        { isHomeMatch: true, goalsFor: 1, goalsAgainst: 0 },
        { isHomeMatch: false, goalsFor: 2, goalsAgainst: 0 },
      ],
      rijeka: [
        { isHomeMatch: true, goalsFor: 1, goalsAgainst: 3 },
        { isHomeMatch: false, goalsFor: 2, goalsAgainst: 3 },
      ],
      osijek: [
        { isHomeMatch: true, goalsFor: 1, goalsAgainst: 1 },
        { isHomeMatch: false, goalsFor: 1, goalsAgainst: 1 },
      ],
    },
  },
  {
    name: "Dinamo",
    matches: {
      hajduk: [
        { isHomeMatch: false, goalsAgainst: 1, goalsFor: 0 },
        { isHomeMatch: true, goalsAgainst: 2, goalsFor: 0 },
      ],
      rijeka: [
        { isHomeMatch: true, goalsFor: 3, goalsAgainst: 3 },
        { isHomeMatch: false, goalsFor: 2, goalsAgainst: 1 },
      ],
      osijek: [
        { isHomeMatch: true, goalsFor: 0, goalsAgainst: 0 },
        { isHomeMatch: false, goalsFor: 2, goalsAgainst: 2 },
      ],
    },
  },
  {
    name: "Osijek",
    matches: {
      dinamo: [
        { isHomeMatch: true, goalsFor: 2, goalsAgainst: 2 },
        { isHomeMatch: false, goalsFor: 0, goalsAgainst: 0 },
      ],
      rijeka: [
        { isHomeMatch: true, goalsFor: 1, goalsAgainst: 1 },
        { isHomeMatch: false, goalsFor: 1, goalsAgainst: 0 },
      ],
      hajduk: [
        { isHomeMatch: true, goalsFor: 1, goalsAgainst: 1 },
        { isHomeMatch: false, goalsFor: 1, goalsAgainst: 1 },
      ],
    },
  },
  {
    name: "Rijeka",
    matches: {
      dinamo: [
        { isHomeMatch: true, goalsFor: 1, goalsAgainst: 2 },
        { isHomeMatch: false, goalsFor: 3, goalsAgainst: 3 },
      ],
      hajduk: [
        { isHomeMatch: true, goalsFor: 3, goalsAgainst: 3 },
        { isHomeMatch: false, goalsFor: 3, goalsAgainst: 1 },
      ],
      osijek: [
        { isHomeMatch: true, goalsFor: 0, goalsAgainst: 1 },
        { isHomeMatch: false, goalsFor: 0, goalsAgainst: 1 },
      ],
    },
  },
];

const standings = simpleTableStandings(teamsMatches);

Input Type

type Match = {
  isHomeMatch: boolean;
  goalsFor: number;
  goalsAgainst: number;
};

type Team = {
  name: string;
  matches: {
    [opponent: string]: Match[];
  };
};

Output Type

type ExtendedTeam = Team & {
  points: number;
  goalsFor: number;
  goalsAgainst: number;
  goalDiff: number;
  records?: {
    [opponent: string]: {
      points: number;
      goals: number;
    };
  };
};

Example Output

[
  {
    "name": "Hajduk",
    "points": 8,
    "goalsFor": 8,
    "goalsAgainst": 8,
    "goalDiff": 0,
    "records": {
      "dinamo": { "points": 2, "goals": 3 },
      "rijeka": { "points": -1, "goals": -3 }
    }
  }
  // ... more teams
]

Rules

  • Win: 3 points
  • Draw: 1 point
  • Loss: 0 points

Teams are sorted by (in order of priority):

  1. Total points
  2. Head-to-head matches (points earned in matches between tied teams)
  3. Overall goal difference
  4. Total goals scored

For example, if two teams have the same points:

  • First, compare their head-to-head matches
  • If still tied, compare their goal differences
  • If still tied, compare total goals scored

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

License

ISC