fit-file-parser 1.20.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +29 -0
- package/CHANGELOG.md +22 -22
- package/CONTRIBUTORS.md +3 -1
- package/README.md +39 -21
- package/dist/binary.d.ts +11 -0
- package/dist/binary.js +181 -221
- package/dist/fit-parser.d.ts +19 -0
- package/dist/fit-parser.js +232 -252
- package/dist/fit.d.ts +52 -0
- package/dist/fit.js +7886 -4295
- package/dist/helper.d.ts +3 -0
- package/dist/helper.js +63 -66
- package/dist/messages.d.ts +6 -0
- package/dist/messages.js +19 -20
- package/dist/types.d.ts +55 -0
- package/dist/types.js +1 -0
- package/eslint.config.js +7 -0
- package/package.json +38 -48
- package/tsconfig.json +15 -0
- package/vitest.config.js +8 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [20.x, 22.x, 24.x, 25.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v6
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v6
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- run: npm run build
|
|
25
|
+
- run: npm run test
|
|
26
|
+
- run: npm run lint
|
|
27
|
+
if: matrix.node-version == '25.x'
|
|
28
|
+
- run: npm run type-check
|
|
29
|
+
if: matrix.node-version == '25.x'
|
package/CHANGELOG.md
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
3
|
<a name="1.5.4"></a>
|
|
4
|
+
|
|
4
5
|
## [1.5.4](https://github.com/jimmykane/fit-parser/compare/v1.0.0...v1.5.3) (2019-03-01)
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
- **Features**: HRV, Developer fields, devices and much more
|
|
8
|
+
- **Miscellaneous**: Fix most of the issues parsing fit files
|
|
7
9
|
|
|
8
10
|
<a name="1.0.1"></a>
|
|
9
|
-
## [1.0.1](https://github.com/pierremtb/easy-fit/compare/v1.0.0...v1.0.1) (2018-09-18)
|
|
10
11
|
|
|
12
|
+
## [1.0.1](https://github.com/pierremtb/easy-fit/compare/v1.0.0...v1.0.1) (2018-09-18)
|
|
11
13
|
|
|
12
14
|
### 😭 Unclassified (not [following convention](https://github.com/sportheroes/bk-conventional-changelog#types-of-commits))
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
- **Miscellaneous**: fix: Applied to src/fit offset adjustments from commit 9ed802 ([70b3eb6](https://github.com/pierremtb/easy-fit/commit/70b3eb6) - [JoeTheFkingFrypan](https://github.com/JoeTheFkingFrypan))
|
|
17
17
|
|
|
18
18
|
<a name="1.0.0"></a>
|
|
19
|
-
# [1.0.0](https://github.com/pierremtb/easy-fit/compare/0.0.7...1.0.0) (2018-09-17)
|
|
20
19
|
|
|
20
|
+
# [1.0.0](https://github.com/pierremtb/easy-fit/compare/0.0.7...1.0.0) (2018-09-17)
|
|
21
21
|
|
|
22
22
|
### 😭 Unclassified (not [following convention](https://github.com/sportheroes/bk-conventional-changelog#types-of-commits))
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
- **Miscellaneous**: Fix readme typo ([2282c06](https://github.com/pierremtb/easy-fit/commit/2282c06)))
|
|
25
|
+
- **Miscellaneous**: chore: preparing to release fork internally ([3eef5f7](https://github.com/pierremtb/easy-fit/commit/3eef5f7) - [JoeTheFkingFrypan](https://github.com/JoeTheFkingFrypan))
|
|
26
|
+
- **Miscellaneous**: fix: Typo leading to uint16 to never be invalidated ([9ed802c](https://github.com/pierremtb/easy-fit/commit/9ed802c) - [JoeTheFkingFrypan](https://github.com/JoeTheFkingFrypan))
|
|
27
|
+
- **Miscellaneous**: Merge remote-tracking branch 'jenglert/master' ([819d78e](https://github.com/pierremtb/easy-fit/commit/819d78e)))
|
|
28
|
+
- **Miscellaneous**: fix missing buffer dependency and compile dst ([a4b237a](https://github.com/pierremtb/easy-fit/commit/a4b237a)))
|
|
29
|
+
- **Miscellaneous**: Merge remote-tracking branch 'FrostDigital/master' ([6fa9258](https://github.com/pierremtb/easy-fit/commit/6fa9258)))
|
|
30
|
+
- **Miscellaneous**: Makes parsing of fit files with developer defined fields possible (#1) ([9aea666](https://github.com/pierremtb/easy-fit/commit/9aea666))), closes [#1](https://github.com/pierremtb/easy-fit/issues/1)
|
|
31
|
+
- **Miscellaneous**: fix: Adjusted offset for all altitude-related fields ([1ff0fa4](https://github.com/pierremtb/easy-fit/commit/1ff0fa4) - [JoeTheFkingFrypan](https://github.com/JoeTheFkingFrypan))
|
|
32
|
+
- **Miscellaneous**: chore(devices): add forerunner 735 xt ([aacaa04](https://github.com/pierremtb/easy-fit/commit/aacaa04)))
|
|
33
|
+
- **Miscellaneous**: Compile src ([ee4aa00](https://github.com/pierremtb/easy-fit/commit/ee4aa00)))
|
|
34
|
+
- **Miscellaneous**: Add support for other lap types ([dcf42a1](https://github.com/pierremtb/easy-fit/commit/dcf42a1)))
|
|
35
|
+
- **Miscellaneous**: Compile src ([50b9b21](https://github.com/pierremtb/easy-fit/commit/50b9b21)))
|
|
36
|
+
- **Miscellaneous**: Merge remote-tracking branch 'pierremtb/master' ([f7f5ff0](https://github.com/pierremtb/easy-fit/commit/f7f5ff0)))
|
|
37
|
+
- **Miscellaneous**: Add support for more manufacturers ([2d122d2](https://github.com/pierremtb/easy-fit/commit/2d122d2)))
|
|
38
|
+
- **Miscellaneous**: Really compiled last changes on binary.js this time, small details on package.json file -> bumped to 0.0.8 ([e5dc98f](https://github.com/pierremtb/easy-fit/commit/e5dc98f)))
|
package/CONTRIBUTORS.md
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# fit-file-parser
|
|
2
2
|
|
|
3
3
|
> Parse your .FIT files easily, directly from JS.
|
|
4
|
-
> Written in
|
|
5
|
-
|
|
4
|
+
> Written in Typescript
|
|
6
5
|
|
|
7
6
|
## Install
|
|
8
7
|
|
|
@@ -14,16 +13,18 @@ $ npm install fit-file-parser --save
|
|
|
14
13
|
|
|
15
14
|
See in [examples](./examples) folder:
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
// Require the module
|
|
19
|
-
var FitParser = require('./../dist/fit-file-parser.js').default;
|
|
16
|
+
### using callbacks
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
```javascript
|
|
19
|
+
import fs from 'node:fs/promises'
|
|
20
|
+
import FitParser from 'fit-file-parser'
|
|
24
21
|
|
|
22
|
+
fs.readFile('./example.fit', (err, content) => {
|
|
25
23
|
// Create a FitParser instance (options argument is optional)
|
|
26
|
-
|
|
24
|
+
if (err) {
|
|
25
|
+
console.error(err)
|
|
26
|
+
}
|
|
27
|
+
const fitParser = new FitParser({
|
|
27
28
|
force: true,
|
|
28
29
|
speedUnit: 'km/h',
|
|
29
30
|
lengthUnit: 'km',
|
|
@@ -31,28 +32,39 @@ fs.readFile('./example.fit', function (err, content) {
|
|
|
31
32
|
pressureUnit: 'bar', // accept bar, cbar and psi (default is bar)
|
|
32
33
|
elapsedRecordField: true,
|
|
33
34
|
mode: 'cascade',
|
|
34
|
-
})
|
|
35
|
-
|
|
35
|
+
})
|
|
36
|
+
|
|
36
37
|
// Parse your file
|
|
37
|
-
fitParser.parse(content,
|
|
38
|
-
|
|
38
|
+
fitParser.parse(content, (error, data) => {
|
|
39
39
|
// Handle result of parse method
|
|
40
40
|
if (error) {
|
|
41
|
-
console.
|
|
42
|
-
}
|
|
43
|
-
|
|
41
|
+
console.error(error)
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log(JSON.stringify(data))
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
46
|
+
})
|
|
47
|
+
})
|
|
49
48
|
```
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
### using async/await
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import fs from 'node:fs/promises'
|
|
54
|
+
import FitParser from 'fit-file-parser'
|
|
55
|
+
|
|
56
|
+
const buffer = await fs.readFile('./example.fit')
|
|
57
|
+
const fitObject = await fitParser.parseAsync(buffer)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API Documentation
|
|
61
|
+
|
|
52
62
|
### new FitParser(Object _options_)
|
|
63
|
+
|
|
53
64
|
Needed to create a new instance. _options_ is optional, and is used to customize the returned object.
|
|
54
65
|
|
|
55
66
|
Allowed properties :
|
|
67
|
+
|
|
56
68
|
- `mode`: String
|
|
57
69
|
- `cascade`: Returned object is organized as a tree, eg. each lap contains a `records` fields, that is an array of its records (**default**)
|
|
58
70
|
- `list`: Returned object is organized as lists of sessions, laps, records, etc..., without parent-child relation
|
|
@@ -77,9 +89,15 @@ Allowed properties :
|
|
|
77
89
|
- `false` (**default**)
|
|
78
90
|
|
|
79
91
|
### fitParser.parse(Buffer _file_, Function _callback_)
|
|
92
|
+
|
|
80
93
|
_callback_ receives two arguments, the first as a error String, and the second as Object, result of parsing.
|
|
81
94
|
|
|
95
|
+
### fitParser.parseAsync(Buffer _file_)
|
|
96
|
+
|
|
97
|
+
returns a Promise that resolves to the result of parsing.
|
|
98
|
+
|
|
82
99
|
## Contributors
|
|
100
|
+
|
|
83
101
|
All started thanks to [Pierre Jacquier](https://github.com/pierremtb)
|
|
84
102
|
|
|
85
103
|
Big thanks to [Mikael Lofjärd](https://github.com/mlofjard) for [his early prototype](https://github.com/mlofjard/jsonfit).
|
package/dist/binary.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FitParserOptions } from './fit-parser.js';
|
|
2
|
+
import type { MessageName } from './fit.js';
|
|
3
|
+
import { Buffer } from 'node:buffer';
|
|
4
|
+
export declare function addEndian(littleEndian: boolean, bytes: number[]): number;
|
|
5
|
+
export declare function readRecord(blob: Uint8Array, messageTypes: any[], developerFields: any[], startIndex: number, options: FitParserOptions, startDate: number | undefined, pausedTime: number): {
|
|
6
|
+
messageType: MessageName | '';
|
|
7
|
+
nextIndex: number;
|
|
8
|
+
message?: any;
|
|
9
|
+
};
|
|
10
|
+
export declare function getArrayBuffer(buffer: ArrayBuffer | Buffer): ArrayBuffer;
|
|
11
|
+
export declare function calculateCRC(blob: Uint8Array, start: number, end: number): number;
|