import { comparator } from './constants' ; export function parseRegex ( source ) { return new RegExp ( source ) ; } export function isXVersion ( version ) { return ! version || version . toLowerCase ( ) === 'x' || version === '*' ; } export function pipe < TArgs extends any [ ] , R1 , R2 , R3 , R4 , R5 , R6 , R7 > ( f1 , f2 , f3 , f4 , f5 , f6 , f7 ) ; export function pipe < TArgs extends any [ ] , R1 , R2 , R3 , R4 , R5 , R6 > ( f1 , f2 , f3 , f4 , f5 , f6 ) ; export function pipe < TArgs extends any [ ] , R1 , R2 , R3 , R4 , R5 > ( f1 , f2 , f3 , f4 , f5 ) ; export function pipe < TArgs extends any [ ] , R1 , R2 , R3 , R4 > ( f1 , f2 , f3 , f4 ) ; export function pipe < TArgs extends any [ ] , R1 , R2 , R3 > ( f1 , f2 , f3 ) ; export function pipe < TArgs extends any [ ] , R1 , R2 > ( f1 , f2 ) ; export function pipe < TArgs extends any [ ] , R1 > ( f1 ) ; export function pipe ( ... fns ) { return ( x ) : any => { return fns . reduce ( ( v , f ) => f ( v ) , x ) ; } ; } export function extractComparator ( comparatorString ) { return comparatorString . match ( parseRegex ( comparator ) ) ; } export function combineVersion ( major , minor , patch , preRelease ) { const mainVersion = `${ major }.${ minor }.${ patch }` ; if ( preRelease ) { return `${ mainVersion }-${ preRelease }` ; } return mainVersion ; }