import { Pipe , PipeTransform } from '@angular/core' ; import { Wallet } from '../../providers/providers' ; @ Pipe ( { name : 'convertUnitPipe' , } ) export class ConvertUnitPipe implements PipeTransform { constructor ( public wallet ) { } transform ( amountSAT , ... args ) { let comma = args [ 1 ] === 'comma' ; let result ; if ( args [ 0 ] === 'SATS' && ! comma ) { result = amountSAT ; } else { result = this . wallet . convertUnit ( 'SATS' , args [ 0 ] , amountSAT , comma ) ; } if ( typeof result === 'undefined' ) { return '' ; } return result ; } }