param methodParams param method param onExecuted export function Executor < T = any > ( methodParams = [ ] , method , onExecuted ? ) { let _resolve = null ; let executeMethods = ( idx = 0 ) => { let returnVal = idx < methodParams . length ? method ( methodParams [ idx ] ) : null ; if ( returnVal && returnVal . then ) { returnVal . then ( ( ... args ) => { if ( onExecuted ) { let returnVal = onExecuted . apply ( this , args ) ; if ( returnVal && returnVal . then ) { returnVal . then ( ( ) => { executeMethods ( idx + 1 ) ; } ) ; } else { executeMethods ( idx + 1 ) ; } } else { executeMethods ( idx + 1 ) ; } } ) ; } else if ( idx < methodParams . length ) { executeMethods ( idx + 1 ) ; } else { _resolve ( ) ; } } ; return new Promise ( ( resolve , reject ) => { _resolve = resolve ; if ( methodParams . length > 0 ) { executeMethods ( ) ; } else { _resolve ( ) ; } } ) ; }