function compareSemVer ( a , b ) { const regExStrip0 = /(\.0+)+$/ ; const segmentsA = a . replace ( regExStrip0 , '' ) . split ( '.' ) ; const segmentsB = b . replace ( regExStrip0 , '' ) . split ( '.' ) ; const l = Math . min ( segmentsA . length , segmentsB . length ) ; for ( let i = 0 ; i < l ; i ++ ) { const diff = parseInt ( segmentsA [ i ] , 10 ) - parseInt ( segmentsB [ i ] , 10 ) ; if ( diff ) return diff ; } return segmentsA . length - segmentsB . length ; } export { compareSemVer } ;