index.js 1017 Bytes
/**
 * Created by TaoHuang on 2016/10/26.
 */


'use strict';

exports.if_cond = (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);
    }
};