import { IProtocolConstructor , IProtocolMap , ProtocolType } from '../types' ; import { BinaryProtocol } from './BinaryProtocol' ; import { CompactProtocol } from './CompactProtocol' ; import { JSONProtocol } from './JSONProtocol' ; export * from './BinaryProtocol' ; export * from './CompactProtocol' ; export * from './JSONProtocol' ; export * from './TProtocol' ; const protocols = { binary : BinaryProtocol , compact : CompactProtocol , json : JSONProtocol , } ; export const supportedProtocols = Object . keys ( protocols ) ; export function isProtocolSupported ( protocol ) { return supportedProtocols . indexOf ( protocol ) !== - 1 ; } export function getProtocol ( protocol = 'binary' ) { if ( protocol && ! isProtocolSupported ( protocol ) ) { throw new Error ( `Invalid protocol specified. Supported values: ${ supportedProtocols . join ( ', ' ) }` ) ; } return protocols [ protocol ] ; }