npm.io
0.4.0 • Published 2d ago

@glaivepro/wa-calculator

Licence
ISC
Version
0.4.0
Deps
0
Size
84 kB
Vulns
0
Weekly
0
Stars
2

WA Calculator

Point calculators for track & field events

For PHP version of this library see GlaivePro/IaafPoints.

Installation

No CDN support at the moment, you have to import and bundle it yourself.

npm i @glaivepro/wa-calculator

Usage

import { WaCalculator } from '@glaivepro/wa-calculator'

const options = {
	edition: '2017', // edition of scoring tables ('2017', '2022' or '2025'), default is '2017'
	gender: 'm', // 'm' or 'f', default is 'm'
	venueType: 'outdoor', // 'indoor' or 'outdoor', default is 'outdoor' --- used by the '2017' and '2022' editions
	trackType: 'long', // 'long' or 'short', default is 'long' --- used by the '2025' and later editions
	electronicMeasurement: true, // whether electronic or hand time was taken, default is true
	discipline: '200m', // no default, see below how to list available keys
}

const calculator = new WaCalculator(options)

// Evaluate a result getting some points or a class assigned to result.
const points = calculator.evaluate(21.61) // 980

// Update options
calculator.setOptions({ gender : 'f' })
const femalePoints = calculator.evaluate(21.61) // 1279

// Get list of editions
calculator.getEditions()

// Get list of discipline keys available for current edition, venueType and gender
calculator.getDisciplines()

Some options for advanced usage:

// Get calculation coefficients for current setup
calculator.getCoefficients()

// Calculate from result using given coefficients
const resultShift = -110
const conversionFactor = 0.335
const pointShift = 0
calculator.evaluateUsing(result, { resultShift, conversionFactor, pointShift })

TODO/wishlist

  • WA (Hungarian) points calculator
  • WA (Hungarian) points 2022
  • Combined points calculator
  • Dist for browser support
  • TS support

Keywords