import { Pipe , PipeTransform } from '@angular/core' ; param value param unitsFrom return @ Pipe ( { name : 'sharedMilesKilometers' } ) export class MilesKilometersPipe implements PipeTransform { transform ( value , unitsFrom ) { const CONVERT_VALUE = 1.609344 ; if ( ! value ) { return null ; } if ( value && unitsFrom ) { if ( unitsFrom . toLowerCase ( ) === 'tomiles' ) { return Math . abs ( value / CONVERT_VALUE ) ; } if ( unitsFrom . toLowerCase ( ) === 'tokilometers' ) { return Math . abs ( value * CONVERT_VALUE ) ; } } return Math . abs ( value * CONVERT_VALUE ) ; } }