if_cond.js 1021 Bytes
/**
 * Created by TaoHuang on 2016/10/26.
 */


'use strict';

module.exports = function(left, operator, right, options) {
    switch (operator) {
        case '==':
            return (left == right) ? options.fn(this) : options.inverse(this); // eslint-disable-line
        case '===':
            return (left === right) ? options.fn(this) : options.inverse(this);
        case '<':
            return (left < right) ? options.fn(this) : options.inverse(this);
        case '<=':
            return (left <= right) ? options.fn(this) : options.inverse(this);
        case '>':
            return (left > right) ? options.fn(this) : options.inverse(this);
        case '>=':
            return (left >= right) ? options.fn(this) : options.inverse(this);
        case '&&':
            return (left && right) ? options.fn(this) : options.inverse(this);
        case '||':
            return (left || right) ? options.fn(this) : options.inverse(this);
        default:
            return options.inverse(this);
    }
};