import { Pipe , PipeTransform } from '@angular/core' ; import { FormatterService } from '@core/formatter.service' ; @ Pipe ( { name : 'eventDepth' } ) export class EventDepthPipe implements PipeTransform { constructor ( public formatter ) { } param event param precision { optional } return transform ( event , precision ? ) { let depth ; try { depth = parseFloat ( event . geometry . coordinates [ 2 ] ) ; } catch { depth = NaN ; } return this . formatter . depth ( depth , 'km' ) + ' depth' ; } }