Parse your .FIT files easily, directly from JS. Written in ES6. (Hope to change)
$ npm install fit-file-parser --save
See in examples folder:
// Require the modulevarFitParser=require('./../dist/fit-file-parser.js').default;// Read a .FIT filevarfs=require('fs');fs.readFile('./example.fit',function(err,content){// Create a FitParser instance (options argument is optional)varfitParser=newFitParser({force: true,speedUnit: 'km/h',lengthUnit: 'km',temperatureUnit: 'kelvin',elapsedRecordField: true,mode: 'cascade',});// Parse your filefitParser.parse(content,function(error,data){// Handle result of parse methodif(error){console.log(error);}else{console.log(JSON.stringify(data));}});});Needed to create a new instance. options is optional, and is used to customize the returned object.
Allowed properties :
mode: Stringcascade: Returned object is organized as a tree, eg. each lap contains arecordsfields, that is an array of its records (default)list: Returned object is organized as lists of sessions, laps, records, etc..., without parent-child relationboth: A mix of the two other modes, eg.recordsare available inside the root field as well as inside each laps
lengthUnit: Stringm: Lengths are in meters (default)km: Lengths are in kilometersmi: Lengths are in miles
temperatureUnit: Stringcelsius:Temperatures are in °C (default)kelvin: Temperatures are in °Kfahrenheit: Temperatures are in °F
speedUnit: Stringm/s: Speeds are in meters per seconds (default)km/h: Speeds are in kilometers per hourmph: Speeds are in miles per hour
force: Booleantrue: Continues even if they are errors (default for now)false: Stops if an error occurs
elapsedRecordField: Booleantrue: Includeselapsed_time, containing the elapsed time in seconds since the first record, andtimer_time, containing the time shown on the device, inside eachrecordfieldfalse(default)
callback receives two arguments, the first as a error String, and the second as Object, result of parsing.
All started thanks to Pierre Jacquier
Big thanks to Mikael Lofjärd for his early prototype. See CONTRIBUTORS.
MIT license; see LICENSE.
(c) 2019 Dimitrios Kanellopoulos