import { channel , IModulePatcher , PatchFunction } from "diagnostic-channel" ; import { EventEmitter } from "events" ; import * as pg from "pg" ; function postgresPool1PatchFunction ( originalPgPool ) { const originalConnect = originalPgPool . prototype . connect ; originalPgPool . prototype . connect = function connect ( callback ? ) : void | Promise < pg . PoolClient > { if ( callback ) { arguments [ 0 ] = channel . bindToContext ( callback ) ; } return originalConnect . apply ( this , arguments ) ; } ; return originalPgPool ; } export const postgresPool1 = { versionSpecifier : ">= 1.0.0 < 3.0.0" , patch : postgresPool1PatchFunction , } ; export function enable ( ) { channel . registerMonkeyPatch ( "pg-pool" , postgresPool1 ) ; }