export const enum ApmMlDetectorType { txLatency = 'txLatency' , txThroughput = 'txThroughput' , txFailureRate = 'txFailureRate' } const detectorIndices = { [ ApmMlDetectorType . txLatency ] : 0 , [ ApmMlDetectorType . txThroughput ] : 1 , [ ApmMlDetectorType . txFailureRate ] : 2 , } ; export function getApmMlDetectorIndex ( type ) { return detectorIndices [ type ] ; } export function getApmMlDetectorType ( detectorIndex ) { let type ; for ( type in detectorIndices ) { if ( detectorIndices [ type ] === detectorIndex ) { return type ; } } throw new Error ( 'Could not map detector index to type' ) ; }