param oldFunc param newFunc export function patchAfter ( oldFunc , newFunc ) { function patch ( this , ... args ) { const ret = oldFunc . apply ( this , args ) ; return newFunc . apply ( this , [ ret , ... args ] ) ; } return patch ; } param oldFunc param newFunc export function patchBefore ( oldFunc , newFunc ) { function patch ( this , ... args ) { const ret = newFunc . apply ( this , args ) ; return typeof ret === 'undefined' ? oldFunc . apply ( this , args ) : ret ; } return patch ; } param prototypeToPatch param PatchClass export function patchClass ( prototypeToPatch , PatchClass ) { const properties = { ... Object . getOwnPropertyDescriptors ( new PatchClass ( ) ) , ... Object . getOwnPropertyDescriptors ( PatchClass . prototype ) , } ; Object . defineProperties ( prototypeToPatch , properties ) ; }