import BigNumber from 'bignumber.js' ; import { map , switchMap } from 'rxjs/operators' ; import { iif , Observable , of , OperatorFunction , defer } from 'rxjs' ; import { MinimalToken } from '@shared/models/tokens/minimal-token' ; param object1 param object2 export function compareObjects ( object1 , object2 ) { return JSON . stringify ( object1 ) === JSON . stringify ( object2 ) ; } param object export function copyObject < T > ( object ) { return JSON . parse ( JSON . stringify ( object ) ) ; } param address0 param address1 export function compareAddresses ( address0 , address1 ) { return address0 . toLowerCase ( ) === address1 . toLowerCase ( ) ; } param token0 param token1 export function compareTokens ( token0 , token1 ) { return ( token0 . address . toLowerCase ( ) === token1 . address . toLowerCase ( ) && token0 . blockchain === token1 . blockchain ) ; } param amount param percent export function subtractPercent ( amount , percent ) { return new BigNumber ( amount ) . multipliedBy ( new BigNumber ( 1 ) . minus ( percent ) ) ; } /**
 * Maps stream to void: emits, and completes the stream.
 */ export function mapToVoid ( ) { return switchMap ( ( ) => of ( undefined ) ) ; } /**
 * Await for side-effect action like switchMap, but not modify the stream
 */ export function switchTap < T > ( handler ) { return switchMap ( arg => { return handler ( arg ) . pipe ( map ( ( ) => arg ) ) ; } ) ; } param condition param trueResultFn param falseResultFn export function switchIif < A = void , T = never , F = never > ( condition , trueResultFn , falseResultFn ) { return switchMap ( ( args ) => iif ( ( ) => condition ( args ) , defer ( ( ) => trueResultFn ( args ) ) , defer ( ( ) => falseResultFn ( args ) ) ) ) ; } export function getBigNumber ( num ) { return num === undefined || num === null ? 0 : parseFloat ( num . toString ( ) ) ; }