lib/forest.js
function (constraint) {
        let first = /((?:\d+(?:\.\d+){0,2}))\s+(\<=|\>=|\<|\>)\s+v/;
        let second = /v\s+(\<=|\>=|\<|\>)\s+((?:\d+(?:\.\d+){0,2}))/;
        let firstMatch = constraint.match(first);
        let secondMatch = constraint.match(second);
        ;
        let alwaysFail = (v) => false;
        let firstOp = {
            '<': (a) => (v) => a < v,
            '<=': (a) => (v) => a <= v,
            '>': (a) => (v) => a > v,
            '>=': (a) => (v) => a >= v,
        };
        let secondOp = {
            '<': (a) => (v) => v < a,
            '<=': (a) => (v) => v <= a,
            '>': (a) => (v) => v > a,
            '>=': (a) => (v) => v >= a,
        };
        if (firstMatch && secondMatch) {
            let firstVersion = parseVersionString(firstMatch[1]);
            let secondVersion = parseVersionString(secondMatch[2]);
            return [
                firstVersion ? firstOp[firstMatch[2]](firstVersion) : alwaysFail,
                secondVersion ? secondOp[secondMatch[1]](secondVersion) : alwaysFail
            ];
        }
        return null;
    }
function (constraint) {
        let first = /((?:\d+(?:\.\d+){0,2}))\s+(\<=|\>=|\<|\>)\s+v/;
        let second = /v\s+(\<=|\>=|\<|\>)\s+((?:\d+(?:\.\d+){0,2}))/;
        let firstMatch = constraint.match(first);
        let secondMatch = constraint.match(second);
        ;
        let alwaysFail = (v) => false;
        let firstOp = {
            '<': (a) => (v) => a < v,
            '<=': (a) => (v) => a <= v,
            '>': (a) => (v) => a > v,
            '>=': (a) => (v) => a >= v,
        };
        let secondOp = {
            '<': (a) => (v) => v < a,
            '<=': (a) => (v) => v <= a,
            '>': (a) => (v) => v > a,
            '>=': (a) => (v) => v >= a,
        };
        if (firstMatch && secondMatch) {
            let firstVersion = parseVersionString(firstMatch[1]);
            let secondVersion = parseVersionString(secondMatch[2]);
            return [
                firstVersion ? firstOp[firstMatch[2]](firstVersion) : alwaysFail,
                secondVersion ? secondOp[secondMatch[1]](secondVersion) : alwaysFail
            ];
        }
        return null;
    }
function ( constraint ) { let first = / ((?:\d+(?:\.\d+){0,2}))\s+(\<=|\>=|\<|\>)\s+v / ; let second = / v\s+(\<=|\>=|\<|\>)\s+((?:\d+(?:\.\d+){0,2})) / ; let firstMatch = constraint . match ( first ) ; let secondMatch = constraint . match ( second ) ; ; let alwaysFail = ( v ) => false ; let firstOp = { '<' : ( a ) => ( v ) => a < v , '<=' : ( a ) => ( v ) => a <= v , '>' : ( a ) => ( v ) => a > v , '>=' : ( a ) => ( v ) => a >= v , } ; let secondOp = { '<' : ( a ) => ( v ) => v < a , '<=' : ( a ) => ( v ) => v <= a , '>' : ( a ) => ( v ) => v > a , '>=' : ( a ) => ( v ) => v >= a , } ; if ( firstMatch && secondMatch ) { let firstVersion = parseVersionString ( firstMatch [ 1 ] ) ; let secondVersion = parseVersionString ( secondMatch [ 2 ] ) ; return [ firstVersion ? firstOp [ firstMatch [ 2 ] ] ( firstVersion ) : alwaysFail , secondVersion ? secondOp [ secondMatch [ 1 ] ] ( secondVersion ) : alwaysFail ] ; } return null ; }
Parse a constarint such as `0.18.0 <= v < 0.19.0` into a list of
functions to test against a `v` value
The value of `v` itself should match the type returned by
`parseVersionString`.
Parse a constarint such as 0 . 18 . 0 < = v < 0 . 19 . 0 into a list of functions to test against a v value The value of v itself should match the type returned by parseVersionString .