# scoreboard-lib

> scoreboard library

Latest version **1.0.0** (published 2022-09-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install scoreboard-lib
pnpm add scoreboard-lib
yarn add scoreboard-lib
bun add scoreboard-lib
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-09-29 |
| First published | 2022-09-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Lukasz Korzeniowski |
| Maintainers | lukasz.korzeniowski |

## Links

- npm: https://www.npmjs.com/package/scoreboard-lib
- Repository: https://github.com/lkorzeniowski/scoreboard-library
- Homepage: https://github.com/lkorzeniowski/scoreboard-library#readme
- Issues: https://github.com/lkorzeniowski/scoreboard-library/issues
- npm.io page: https://npm.io/package/scoreboard-lib

## Dependencies (3)

- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [typedi](https://npm.io/package/typedi.md) ^0.10.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 1.0.0 (latest) — 2022-09-29

## README

# scoreboard-lib

Example Node.js library for handling Scoreboard's games. It offers 4 different operations:
- **start** : starts a game by passing home and away teams & returns gameId. Sets a score to 0 - 0
- **update** : update a game score by passing gameId and actual score
- **finish** : finish a game by passing gameId. Game is removed from storage
- **getAllGames** : returns all ongoing games orderd by score and game's start time


## how to use the library

Scoreboard library is a npm module which can be installed locally

```bash
npm i scoreboard-lib
```

If you have a typescript project this is an example usage

```js
import { 
    GameRepositoryImpl, 
    GameRepository,
    ScoreBoardImpl,
    ScoreBoard,
    Team, 
    TeamType 
} from 'scoreboard-lib';

const repo: GameRepository = new GameRepositoryImpl();
const scoreboard: ScoreBoard = new ScoreBoardImpl(repo);

const firstTeamHome: Team = { city: "xxx", name: 'Manchester', type: TeamType.HOME};
const firstTeamAway: Team = { city: "yyy", name: 'Liverpool', type: TeamType.AWAY};
const firstGameId: string = scoreboard.start(firstTeamHome, firstTeamAway);

scoreboard.update(firstGameId,7,0);

const secondTeamHome: Team = { city: "xxx", name: 'Barcelona', type: TeamType.HOME};
const secondTeamAway: Team = { city: "yyy", name: 'Real', type: TeamType.AWAY};
const secondGameId: string = scoreboard.start(secondTeamHome, secondTeamAway);

scoreboard.update(secondGameId,3,1);

scoreboard.getAllGames().map( game => {
    console.log(`${game}`);
});
```

Generally to use a scoreboard-lib module you need to create a game repository first

```js
const repo: GameRepository = new GameRepositoryImpl();
```

and create a score board passing the game repository to the constructor

```js
const scoreboard: ScoreBoard = new ScoreBoardImpl(repo);
```

The intention of game repositpory is to create a data layer allowing different storage types in future.


## unit testing

 To run unit tests locally please download the git project

 ```bash
 git clone git@github.com:lkorzeniowski/scoreboard-library.git
 ```

 and run commands

 ```bash
 npm install
 npm test
 ```

---
_Source: https://npm.io/package/scoreboard-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
