Giter Site home page Giter Site logo

fit-parser's Introduction

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',
    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 :

  • mode: String
    • cascade: Returned object is organized as a tree, eg. each lap contains a records fields, that is an array of its records (default)
    • list: Returned object is organized as lists of sessions, laps, records, etc..., without parent-child relation
    • both: A mix of the two other modes, eg. records are available inside the root field as well as inside each laps
  • lengthUnit: String
    • m: Lengths are in meters (default)
    • km: Lengths are in kilometers
    • mi: Lengths are in miles
  • temperatureUnit: String
    • celsius:Temperatures are in °C (default)
    • kelvin: Temperatures are in °K
    • fahrenheit: Temperatures are in °F
  • speedUnit: String
    • m/s: Speeds are in meters per seconds (default)
    • km/h: Speeds are in kilometers per hour
    • mph: Speeds are in miles per hour
  • force: Boolean
    • true: Continues even if they are errors (default for now)
    • false: Stops if an error occurs
  • elapsedRecordField: Boolean
    • true: Includes elapsed_time, containing the elapsed time in seconds since the first record, and timer_time, containing the time shown on the device, inside each record field
    • false (default)

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

fit-parser's People

Contributors

aengus1 avatar dpwiese avatar dylandevs avatar filipekiss avatar ianforsyth avatar jamespeek avatar jim-englert-zocdoc avatar jimmykane avatar joecorkerton avatar joelso avatar manuelbaun avatar nholden avatar pierremtb avatar srskc avatar themillhousegroup avatar thomas-gruen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.