jimmykane / fit-parser

Parse your FIT files easily, directly from JS (Garmin, Polar, Suunto)
Other
92 stars 33 forks source link
fit garmin polar suunto

fit-file-parser

Parse your .FIT files easily, directly from JS. Written in ES6. (Hope to change)

Install

$ npm install fit-file-parser --save

How to use

See in examples folder:

// Require the module
var FitParser = require('./../dist/fit-file-parser.js').default;

// Read a .FIT file
var fs = require('fs');
fs.readFile('./example.fit', function (err, content) {

  // Create a FitParser instance (options argument is optional)
  var fitParser = new FitParser({
    force: true,
    speedUnit: 'km/h',
    lengthUnit: 'km',
    temperatureUnit: 'kelvin',
    pressureUnit: 'bar', // accept bar, cbar and psi (default is bar)
    elapsedRecordField: true,
    mode: 'cascade',
  });

  // Parse your file
  fitParser.parse(content, function (error, data) {

    // Handle result of parse method
    if (error) {
      console.log(error);
    } else {
      console.log(JSON.stringify(data));
    }

  });

});

API Documentation

new FitParser(Object options)

Needed to create a new instance. options is optional, and is used to customize the returned object.

Allowed properties :

fitParser.parse(Buffer file, Function callback)

callback receives two arguments, the first as a error String, and the second as Object, result of parsing.

Contributors

All started thanks to Pierre Jacquier

Big thanks to Mikael Lofjärd for his early prototype. See CONTRIBUTORS.

License

MIT license; see LICENSE.

(c) 2019 Dimitrios Kanellopoulos