Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rf2-results-parser

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rf2-results-parser

This is a small package that will allow you to transform a results file generated by the popular racing sim, rFactor2.

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

rFactor 2 Results Parser

This is a small package that will allow you to transform a results file generated by the popular racing sim, rFactor2.

As of today the file generated is given to us a very heavy XML document, which is usable, but at the same time probably gives us more information than we need at any given time.

This utility will allow you to pass in a results file and it will parse it into a usable JSON format for you whilst also getting rid of any cruff you may not need right away.

Installation

NPM

npm install rf2-session-parser --save

Yarn

yarn add rf2-session-parser

Usage

Import (CommonJS)

const parseResults = require('rf2-results-parser');

Import (ES6)

import { parseResults } from 'rf2-results-parser';

Using the funtion

How you supply it the file is up to you, but chances are you will be using it within an API. Here is an example when using Node's FS module:

fs.readFile('./race-example.xml', (err, data) => {
  const resultsData = parseResults(data);
  console.log(parsedData);
});

For now the function only takes 1 arguement which is the data from the file you supply. An arguement for certain options will be added in due course.

Response

Here is an example response for a race session:

{ event: 
   { name: 'GPVWC SL Lights Round 7',
     location: 'Istanbul Park (2019)',
     session: 'Race' },
  result: 
   [ { position: '1',
       name: 'Cristian Pasqual',
       team: 'TR Bluvos Motorsport',
       car: 'GPVWC Superleague Lights 2019',
       raceTime: '01:07:28.205',
       lapsCompleted: '47',
       gapToFirst: null,
       pitstops: '2' },
     { position: '2',
       name: 'Mark Hutchinson',
       team: 'Idos Motorsport',
       car: 'GPVWC Superleague Lights 2019',
       raceTime: '01:07:28.599',
       lapsCompleted: '47',
       gapToFirst: '00:00:00.393',
       pitstops: '2' },
     { position: '3',
       name: 'Laurent Keersmaekers',
       team: 'Holland Racing Team',
       car: 'GPVWC Superleague Lights 2019',
       raceTime: '01:07:36.392',
       lapsCompleted: '47',
       gapToFirst: '00:00:08.186',
       pitstops: '2' },
     { position: '4',
       name: 'Michi Hoyer',
       team: 'Red Arrow Racing',
       car: 'GPVWC Superleague Lights 2019',
       raceTime: '01:07:41.912',
       lapsCompleted: '47',
       gapToFirst: '00:00:13.707',
       pitstops: '2' },
     { position: '5',
       name: 'Matthew Williams ',
       team: 'Red Arrow Racing',
       car: 'GPVWC Superleague Lights 2019',
       raceTime: '01:07:45.566',
       lapsCompleted: '47',
       gapToFirst: '00:00:17.361',
       pitstops: '2' },
     { position: '6',
       name: 'Noah Chilla',
       team: 'Cenobite Motorsports',
       car: 'GPVWC Superleague Lights 2019',
       raceTime: 'DNF',
       lapsCompleted: '38',
       gapToFirst: 'DNF',
       pitstops: '1' },

Options

pointsAwarded

Type: object

Description: Will apply a points value to each of the drivers results data set based on where they have finished

Usage:

const points = {
  "1": 10,
  "2": 8,
  "3": 6,
  "4": 4,
  "5": 2,
  "6": 1,
}

const resultsData = parseResults(data, { pointsAwarded: points });

Response:

  { position: '5',
    name: 'Matthew Williams ',
    team: 'Red Arrow Racing',
    car: 'GPVWC Superleague Lights 2019',
    raceTime: '01:07:45.566',
    lapsCompleted: '47',
    gapToFirst: '00:00:17.361',
    pitstops: '2',
    pointsAwarded: 2
  },

NOTE: This will only work for race results

FAQs

Package last updated on 21 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc