1.1.8 • Published 2 years ago

tods-matchup-format-code v1.1.8

Weekly downloads
1,904
License
MIT
Repository
github
Last release
2 years ago

TODS MatchUp Format Code

The Tennis Open Data Standards MatchUp Format Codes provide a concise way of describing methods for scoring tennis matches that is both human and machine readble.

SET3-S:6/TB7 is the TODS representation for "Best 2 Out Of 3 Sets (Win By Two) 6 games with Tiebreak to 7

This package includes two methods to make it easier to work with TODS MatchUp Format Codes in projects related to tennis, by transforming valid format codes into JSON and valid JSON objects back into format codes.

Online Documentation with examples

Installation

npm install tods-matchup-format-code

Use

import { matchUpFormatCode } from 'tods-matchup-format-code';

let parsedCode = matchUpFormatCode.parse('SET3-S:6/TB7');

Methods

parse

Converts a TODS MatchUp Format Code into JSON

matchUpFormatCode.parse('SET3-S:6/TB7')

// results in...

{
  bestOf: 3,
  setFormat: { setTo: 6, tiebreakFormat: { tiebreakTo: 7 }, tiebreakAt: 6 }
}

Parsing 'SET3-S:6/TB7-F:TB10' results in:

{
  bestOf: 3;
  finalSetFormat: {
    tiebreakSet: {
      tiebreakTo: 10;
    }
  }
  setFormat: {
    setTo: 6;
    tiebreakAt: 6;
    tiebreakFormat: {
      tiebreakTo: 7;
    }
  }
}

stringify

Converts compliant JSON into a TODS MatchUp Format Code, the reverse of the .parse() method.

machUpFormatCode.stringify(matchUpFormatObject);

isValidMatchUpFormat

Returns boolean indicating whether matchUpFormat is valid.

matchUpFormatCode.isValidMatchUpFormat('SET3-S:6/TB7');
1.1.8

2 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago