import { VersionArray } from './parse' ; export const parse = ( versionArr ) => ( { major : versionArr [ 0 ] , minor : versionArr [ 1 ] , patch : versionArr [ 2 ] , } ) ; export const toString = ( arr ) => `${ arr [ 0 ] }.${ arr [ 1 ] }.${ arr [ 2 ] }` ; export const isNewer = ( versionX , versionY ) => { const parsedX = parse ( versionX ) ; const parsedY = parse ( versionY ) ; if ( parsedX . major - parsedY . major !== 0 ) { return parsedX . major > parsedY . major ; } if ( parsedX . minor - parsedY . minor !== 0 ) { return parsedX . minor > parsedY . minor ; } if ( parsedX . patch - parsedY . patch !== 0 ) { return parsedX . patch > parsedY . patch ; } return false ; } ; export const isEqual = ( versionX , versionY ) => toString ( versionX ) === toString ( versionY ) ; export const isNewerOrEqual = ( versionX , versionY ) => isNewer ( versionX , versionY ) || isEqual ( versionX , versionY ) ;