src/handlebars-helpers.js
function compareValues(lvalue, operator, rvalue, options) {
  const operators = {
    '==': function compareEqual(l, r) { return l === r; },
    '===': function compareIdentical(l, r) { return l === r; },
    '!=': function compareNotEqual(l, r) { return l !== r; },
    '<': function compareLessThan(l, r) { return l < r; },
    '>': function compareGreaterThan(l, r) { return l > r; },
    '<=': function compareLessThanEqual(l, r) { return l <= r; },
    '>=': function compareGreaterThanEqual(l, r) { return l >= r; },
    typeof: function compareTypeOf(l, r) { return typeof l === r; },
  };

  /* istanbul ignore if */
  if (!operators[operator]) {
    throw new Error(util.format('Unknown compare operator: %s', operator));
  }
  const result = operators[operator](lvalue, rvalue);
  if (result) {
    return options.fn(this);
  }

  return options.inverse(this);
}
function compareValues(lvalue, operator, rvalue, options) {
  const operators = {
    '==': function compareEqual(l, r) { return l === r; },
    '===': function compareIdentical(l, r) { return l === r; },
    '!=': function compareNotEqual(l, r) { return l !== r; },
    '<': function compareLessThan(l, r) { return l < r; },
    '>': function compareGreaterThan(l, r) { return l > r; },
    '<=': function compareLessThanEqual(l, r) { return l <= r; },
    '>=': function compareGreaterThanEqual(l, r) { return l >= r; },
    typeof: function compareTypeOf(l, r) { return typeof l === r; },
  };

  /* istanbul ignore if */
  if (!operators[operator]) {
    throw new Error(util.format('Unknown compare operator: %s', operator));
  }
  const result = operators[operator](lvalue, rvalue);
  if (result) {
    return options.fn(this);
  }

  return options.inverse(this);
}
function compareValues ( lvalue , operator , rvalue , options ) { const operators = { '==' : function compareEqual ( l , r ) { return l === r ; } , '===' : function compareIdentical ( l , r ) { return l === r ; } , '!=' : function compareNotEqual ( l , r ) { return l !== r ; } , '<' : function compareLessThan ( l , r ) { return l < r ; } , '>' : function compareGreaterThan ( l , r ) { return l > r ; } , '<=' : function compareLessThanEqual ( l , r ) { return l <= r ; } , '>=' : function compareGreaterThanEqual ( l , r ) { return l >= r ; } , typeof : function compareTypeOf ( l , r ) { return typeof l === r ; } , } ; /* istanbul ignore if */ if ( ! operators [ operator ] ) { throw new Error ( util . format ( 'Unknown compare operator: %s' , operator ) ) ; } const result = operators [ operator ] ( lvalue , rvalue ) ; if ( result ) { return options . fn ( this ) ; } return options . inverse ( this ) ; }
Compare two values with a predicate to determine some
equivelence relation.
@remarks Supported operators are ==, ===, !=, <, >, <= and >=
@param {object}      lvalue        - Left operand
@param {object}      operator      - Comparison operators
@param {object}      rvalue        - Right operand
@param {object}      options       - Handlebars options.
@returns {string}                  - Result
Compare two values with a predicate to determine some equivelence relation .