You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compare.js 763B

1234567891011121314151617181920212223242526272829303132333435
  1. import Ember from 'ember';
  2. export function compare(params) {
  3. if(params[3]){ //handle case insensitive conditions if 4 param is passed.
  4. params[0]= params[0].toLowerCase();
  5. params[2]= params[2].toLowerCase();
  6. }
  7. let v1 = params[0];
  8. let operator = params[1];
  9. let v2 = params[2];
  10. switch (operator) {
  11. case '==':
  12. return (v1 == v2);
  13. case '!=':
  14. return (v1 != v2);
  15. case '===':
  16. return (v1 === v2);
  17. case '<':
  18. return (v1 < v2);
  19. case '<=':
  20. return (v1 <= v2);
  21. case '>':
  22. return (v1 > v2);
  23. case '>=':
  24. return (v1 >= v2);
  25. case '&&':
  26. return !!(v1 && v2);
  27. case '||':
  28. return !!(v1 || v2);
  29. default:
  30. return false;
  31. }
  32. }
  33. export default Ember.Helper.helper(compare);