import { FlyLiveParsedData , FlyLiveFlightData } from './types' ; export default function parseFlyliveData ( data ) { const dataSplit = data . split ( '@!!!!NEWLINEDONOTPUTTHISINTEXT!!!!@' ) ; const flightDataRaw = dataSplit [ 0 ] ; const flightDataSplit = flightDataRaw . split ( '; nextDataSource :' ) ; const altitude = flightDataSplit [ 0 ] ; const heading = flightDataSplit [ 1 ] ; const groundSpeed = flightDataSplit [ 2 ] ; const airSpeed = flightDataSplit [ 3 ] ; const vSpeed = flightDataSplit [ 4 ] ; const planeLat = flightDataSplit [ 5 ] ; const planeLong = flightDataSplit [ 6 ] ; const dep = flightDataSplit [ 7 ] ; const arr = flightDataSplit [ 8 ] ; const callsign = flightDataSplit [ 9 ] ; const dtg = flightDataSplit [ 10 ] ; const distance = flightDataSplit [ 11 ] ; const flightPercent = parseInt ( flightDataSplit [ 12 ] , 10 ) ; const eta = flightDataSplit [ 13 ] ; const ttg = flightDataSplit [ 14 ] ; const simTime = flightDataSplit [ 15 ] ; const realTime = flightDataSplit [ 16 ] ; const isConnected = flightDataSplit [ 17 ] ; const landingRate = flightDataSplit [ 20 ] ; const onGround = flightDataSplit [ 19 ] === 'true' ; const metar = flightDataSplit [ 21 ] ; const fps = flightDataSplit [ 22 ] ; const aircraftType = flightDataSplit [ 23 ] ; const flightData = { altitude , heading , groundSpeed , airSpeed , vSpeed , planeLat , planeLong , dep , arr , callsign , dtg , distance , flightPercent , eta , ttg , simTime , realTime , isConnected , landingRate , onGround , metar , fps , aircraftType , } ; return { flightDataSplit , flightData } ; }