import { RicardianContractProcessor , SpecVersion } from './interfaces' ; export function compareProcessors ( a , b ) { const aVer = a . getSpecVersion ( ) ; const bVer = b . getSpecVersion ( ) ; if ( aVer . major < bVer . major ) { return - 1 ; } if ( aVer . major > bVer . major ) { return 1 ; } if ( aVer . minor < bVer . minor ) { return - 1 ; } if ( aVer . minor > bVer . minor ) { return 1 ; } return 0 ; } export function findProcessorForVersion ( sortedProcessors , specVersion ) { const major = specVersion . major ; const minor = specVersion . minor ; let curProcessor = null ; for ( const processor of sortedProcessors ) { const version = processor . getSpecVersion ( ) ; if ( major === version . major ) { if ( minor <= version . minor ) { curProcessor = processor ; break ; } } } return curProcessor ; }