From 5e5fc6524d78f8a3dc5e3ae87a9e25dca005b40d Mon Sep 17 00:00:00 2001 From: Joao Pedro Henrique Date: Mon, 27 Mar 2023 22:09:03 -0300 Subject: [PATCH] style: format code with prettier --- .../src/flight-decoder/flight-decoder.ts | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/rpl-crawler/src/flight-decoder/flight-decoder.ts b/packages/rpl-crawler/src/flight-decoder/flight-decoder.ts index 05ffb6ac..3719ecd9 100644 --- a/packages/rpl-crawler/src/flight-decoder/flight-decoder.ts +++ b/packages/rpl-crawler/src/flight-decoder/flight-decoder.ts @@ -1,41 +1,45 @@ -import Flight, { FlightRules, WakeTurbulence } from '@mach/common' +import Flight, { FlightRules, WakeTurbulence } from "@mach/common"; import { resolveEstimatedEnrouteMinutes, resolveFlightDate, resolveFlightRules, - resolveWeekDays -} from './flight-decoder-utils' + resolveWeekDays, +} from "./flight-decoder-utils"; const makeFlightDecoder = ({ uuid }: { uuid: (line: string) => string }) => { return (line: string): Flight => { - const LINES = line.split("\n").map(line => line.trim()) + const LINES = line.split("\n").map((line) => line.trim()); const LINE_1 = LINES[0]; - const callsign = LINE_1.match(/[A-Z]{3}\d+/)[0] - const beginDate = resolveFlightDate(LINE_1.match(/(?<= )\d{6}(?= (\d| ))/)[0]); - const endDate = LINE_1.match(/(?<= )(\d{6}|( ){6})(?= [I|V|Y|Z])/)[0] + const callsign = LINE_1.match(/[A-Z]{3}\d+/)[0]; + const beginDate = resolveFlightDate( + LINE_1.match(/(?<= )\d{6}(?= (\d| ))/)[0] + ); + const endDate = LINE_1.match(/(?<= )(\d{6}|( ){6})(?= [I|V|Y|Z])/)[0]; const company = callsign.match(/[A-Z]+/)[0]; const flightNumber = Number(callsign.match(/\d+/)[0]); const departureIcao = LINE_1.substr(-9, 4); - const estimatedOffBlockTime = LINE_1.match(/\d{4}$/)[0] - const flightRules = LINE_1.match(/(?<= ).(?=[A-Z] )/)[0] + const estimatedOffBlockTime = LINE_1.match(/\d{4}$/)[0]; + const flightRules = LINE_1.match(/(?<= ).(?=[A-Z] )/)[0]; const weekDays = LINE_1.match(/(?<= )(\d| ){7}(?= )/)[0].trim(); - const LINE_2 = LINES[1] + const LINE_2 = LINES[1]; const cruisingSpeed = LINE_2.match(/(?<=\/)N\d+/)[0]; const cruisingLevel = Number(LINE_2.match(/(?<=F)\d+/)[0]); - const route = LINE_2.match(/(?<=\/N\d+F\d+ ).*/)[0] + const route = LINE_2.match(/(?<=\/N\d+F\d+ ).*/)[0]; - const LINE_3 = LINES[2] - const arrivalIcao = LINE_3.substring(0, 4) - const estimatedEnrouteMinutes = resolveEstimatedEnrouteMinutes((LINE_3.match(/\d{4}/) ?? ["0000"])[0]) - const remarks = LINE_3.substring(13) + const LINE_3 = LINES[2]; + const arrivalIcao = LINE_3.substring(0, 4); + const estimatedEnrouteMinutes = resolveEstimatedEnrouteMinutes( + (LINE_3.match(/\d{4}/) ?? ["0000"])[0] + ); + const remarks = LINE_3.substring(13); const aircraft = { icaoCode: LINE_1.match(/[A-Z0-9]+(?=(\/(M|L|H|J)))/)[0], wakeTurbulence: LINE_1.match(/(?<=\/)(M|L|H|J)/)[0] as WakeTurbulence, - equipment: remarks.match(/(?<=EQPT\/)[^\s]+/)[0] - } + equipment: remarks.match(/(?<=EQPT\/)[^\s]+/)[0], + }; return { id: uuid(line), @@ -54,9 +58,9 @@ const makeFlightDecoder = ({ uuid }: { uuid: (line: string) => string }) => { flightRules: resolveFlightRules(route), weekdays: resolveWeekDays(weekDays), beginDate, - endDate: endDate.trim() ? resolveFlightDate(endDate) : null - } - } -} + endDate: endDate.trim() ? resolveFlightDate(endDate) : null, + }; + }; +}; -export default makeFlightDecoder +export default makeFlightDecoder;