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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rf2-results-parser

v1.0.0

Published

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

Downloads

2

Readme

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-results-parser --save

Yarn

yarn add rf2-results-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

points

Type: object

Description: This will apply a points score based on race position. YOu can also setup bonus points should you wish to award points for things like pole position or fastest lap

Usage:

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

const resultsData = parseResults(data, { points: 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: {
      racePosition: 2
    }
  },