Fix handling in cases where there are no NRCC messages
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
c1a5ce1fe9
commit
b61851e122
@ -34,10 +34,15 @@ export function transform(input: any): StaffLdb | null {
|
||||
}
|
||||
|
||||
function transformDateTime(input: string): Date {
|
||||
console.log("Transform Date Time Running")
|
||||
return new Date(input);
|
||||
}
|
||||
|
||||
function transformNrcc(input: any): NrccMessage[] | undefined {
|
||||
console.log("Transform Nrcc Running")
|
||||
if (input === undefined) {
|
||||
return input
|
||||
}
|
||||
let output: NrccMessage[] = [];
|
||||
let messages = input;
|
||||
if (!Array.isArray(input?.message)) {
|
||||
@ -57,6 +62,7 @@ function transformNrcc(input: any): NrccMessage[] | undefined {
|
||||
}
|
||||
|
||||
function transformTrainServices(input: any): TrainServices[] {
|
||||
console.log("Transform Train Services Running")
|
||||
let services: any = input?.service;
|
||||
let output: TrainServices[] = [];
|
||||
if (services === undefined) {
|
||||
@ -98,6 +104,7 @@ function transformTrainServices(input: any): TrainServices[] {
|
||||
}
|
||||
|
||||
function transformLocation(input: any): ServiceLocation[] {
|
||||
console.log("Transform Location Running")
|
||||
let output: ServiceLocation[] = [];
|
||||
let locations: any[] = input.location;
|
||||
if (!Array.isArray(input.location)) {
|
||||
@ -116,6 +123,7 @@ function transformLocation(input: any): ServiceLocation[] {
|
||||
}
|
||||
|
||||
export function calculateLength(input: any): number | undefined {
|
||||
console.log("Calculate Length Running")
|
||||
let length: number;
|
||||
if (input?.length) {
|
||||
length = input.length;
|
||||
@ -129,6 +137,7 @@ export function calculateLength(input: any): number | undefined {
|
||||
}
|
||||
|
||||
function transformUnspecifiedDateTime(input: string): Date | undefined {
|
||||
console.log("Transform Unspecified Date Time Running")
|
||||
if (!input) {
|
||||
return undefined;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user