import { InputBufferUnderrunError } from './errors' ; import { IProtocolConstructor , IThriftProcessor , ITransportConstructor , } from './types' ; export * from './types' ; export * from './Int64' ; export * from './protocols' ; export * from './transports' ; export * from './errors' ; export * from './utils' ; export * from './binary' ; export { makeLogger } from './logger' ; export function process < Context > ( args ) { const transportWithData = args . Transport . receiver ( args . buffer ) ; const input = new args . Protocol ( transportWithData ) ; return new Promise ( ( resolve , reject ) : void => { const output = new args . Protocol ( new args . Transport ( ) ) ; args . processor . process ( input , output , args . context ) . then ( ( result ) => { resolve ( result ) ; transportWithData . commitPosition ( ) ; } , ( err ) => { if ( err instanceof InputBufferUnderrunError ) { transportWithData . rollbackPosition ( ) ; } reject ( err ) ; } ) ; } ) ; }