chore: eslint fixes for logic/ folder

This commit is contained in:
Paul Bienkowski 2020-11-18 17:24:28 +01:00
parent 5d16c4d541
commit d8975db15a
2 changed files with 15 additions and 15 deletions

View file

@ -1,5 +1,5 @@
function _parseFloat(token) { function _parseFloat(token) {
var f = parseFloat(token); let f = parseFloat(token);
if (isNaN(f)) { if (isNaN(f)) {
f = parseFloat(token.substring(0, 10)); f = parseFloat(token.substring(0, 10));
} }
@ -10,32 +10,32 @@ function _parseFloat(token) {
} }
module.exports.addPointsToTrack = function addPointsToTrack(track, body) { module.exports.addPointsToTrack = function addPointsToTrack(track, body) {
var num = 0; let num = 0;
var start = 0; let start = 0;
var end = 0; let end = 0;
// reference to the array we will mutate // reference to the array we will mutate
var points = track.trackData.points; const points = track.trackData.points;
var currentPoint; let currentPoint;
while (end < body.length) { while (end < body.length) {
start = end; start = end;
while (body[end] != ';' && body[end] != '$' && end < body.length) { while (body[end] !== ';' && body[end] !== '$' && end < body.length) {
end++; end++;
} }
if (body[end] == '$') { if (body[end] === '$') {
// $ is replacing \n as newlines are not allowed in json strings // $ is replacing \n as newlines are not allowed in json strings
num = 0; num = 0;
} }
if (end < body.length) { if (end < body.length) {
var token = body.substr(start, end - start); const token = body.substr(start, end - start);
end++; end++;
if (token.length > 0) { if (token.length > 0) {
if (num == 0 && token == 'Date') { if (num === 0 && token === 'Date') {
// we have a header line, ignore it for now, TODO parse it // we have a header line, ignore it for now, TODO parse it
if (end < body.length) { if (end < body.length) {
while (body[end] != ';' && body[end] != '$' && end < body.length) { while (body[end] !== ';' && body[end] !== '$' && end < body.length) {
end++; end++;
} }
start = end; start = end;

View file

@ -1,7 +1,7 @@
var { addPointsToTrack } = require('./tracks'); const { addPointsToTrack } = require('./tracks');
var TrackInfo = require('./TrackInfo'); const TrackInfo = require('./TrackInfo');
var { test1 } = require('./_tracks_testdata'); const { test1 } = require('./_tracks_testdata');
describe('addPointsToTrack', () => { describe('addPointsToTrack', () => {
it('is a function', () => { it('is a function', () => {
@ -11,7 +11,7 @@ describe('addPointsToTrack', () => {
it('works on the sample data with an empty track', () => { it('works on the sample data with an empty track', () => {
const trackInfo = new TrackInfo({}, { points: [] }); const trackInfo = new TrackInfo({}, { points: [] });
addPointsToTrack(trackInfo, test1); addPointsToTrack(trackInfo, test1);
var points = trackInfo.trackData.points; const points = trackInfo.trackData.points;
expect(points).toHaveLength(324); expect(points).toHaveLength(324);
expect(points[0]).toEqual({ expect(points[0]).toEqual({
date: '12.07.2020', date: '12.07.2020',