license export function patchCallbacks ( api , target , targetName , method , callbacks ) { const symbol = Zone . __symbol__ ( method ) ; if ( target [ symbol ] ) { return ; } const nativeDelegate = target [ symbol ] = target [ method ] ; target [ method ] = function ( name , opts , options ? ) { if ( opts && opts . prototype ) { callbacks . forEach ( function ( callback ) { const source = `${ targetName }.${ method }::` + callback ; const prototype = opts . prototype ; if ( prototype . hasOwnProperty ( callback ) ) { const descriptor = api . ObjectGetOwnPropertyDescriptor ( prototype , callback ) ; if ( descriptor && descriptor . value ) { descriptor . value = api . wrapWithCurrentZone ( descriptor . value , source ) ; api . _redefineProperty ( opts . prototype , callback , descriptor ) ; } else if ( prototype [ callback ] ) { prototype [ callback ] = api . wrapWithCurrentZone ( prototype [ callback ] , source ) ; } } else if ( prototype [ callback ] ) { prototype [ callback ] = api . wrapWithCurrentZone ( prototype [ callback ] , source ) ; } } ) ; } return nativeDelegate . call ( target , name , opts , options ) ; } ; api . attachOriginToPatched ( target [ method ] , nativeDelegate ) ; }