src/util/astUtil.js
function getExpressionComparedToInt(node, value, checkOver) {
    const isValue = getIsValue(value)
    if (_.includes(comparisonOperators, node.operator)) {
        if (isValue(node.right)) {
            return node.left
        }
        if (isValue(node.left)) {
            return node.right
        }
    }
    if (checkOver) {
        if (node.operator === '>' && isValue(node.right)) {
            return node.left
        }
        if (node.operator === '<' && isValue(node.left)) {
            return node.right
        }
        const isNext = getIsValue(value + 1)
        if ((node.operator === '>=' || node.operator === '<') && isNext(node.right)) {
            return node.left
        }
        if ((node.operator === '<=' || node.operator === '>') && isNext(node.left)) {
            return node.right
        }
    }
}
function getExpressionComparedToInt(node, value, checkOver) {
    const isValue = getIsValue(value)
    if (_.includes(comparisonOperators, node.operator)) {
        if (isValue(node.right)) {
            return node.left
        }
        if (isValue(node.left)) {
            return node.right
        }
    }
    if (checkOver) {
        if (node.operator === '>' && isValue(node.right)) {
            return node.left
        }
        if (node.operator === '<' && isValue(node.left)) {
            return node.right
        }
        const isNext = getIsValue(value + 1)
        if ((node.operator === '>=' || node.operator === '<') && isNext(node.right)) {
            return node.left
        }
        if ((node.operator === '<=' || node.operator === '>') && isNext(node.left)) {
            return node.right
        }
    }
}
function getExpressionComparedToInt ( node , value , checkOver ) { const isValue = getIsValue ( value ) if ( _ . includes ( comparisonOperators , node . operator ) ) { if ( isValue ( node . right ) ) { return node . left } if ( isValue ( node . left ) ) { return node . right } } if ( checkOver ) { if ( node . operator === '>' && isValue ( node . right ) ) { return node . left } if ( node . operator === '<' && isValue ( node . left ) ) { return node . right } const isNext = getIsValue ( value + 1 ) if ( ( node . operator === '>=' || node . operator === '<' ) && isNext ( node . right ) ) { return node . left } if ( ( node . operator === '<=' || node . operator === '>' ) && isNext ( node . left ) ) { return node . right } } }
Returns the expression compared to the value in a binary expression, or undefined if there isn't one
@param {Object} node
@param {number} value
@param {boolean} [checkOver=false]
@returns {Object|undefined}
Returns the expression compared to the value in a binary expression or undefined if there isn t one