Brak opisu

comparer.js 870B

123456789101112131415161718192021222324252627282930313233343536
  1. export default {
  2. greater : (a, b) => a > b,
  3. smaller : (a, b) => a < b,
  4. instanceOf : (a, b) => a instanceof b,
  5. typeof : (a, b) => typeof a === b,
  6. IsNull : (a, b) => a === null,
  7. exists : (a, b) => {
  8. return a !== null && a !== void 0
  9. },
  10. equalToArray : (a, b) => {
  11. if(!Array.isArray(a) && Array.isArray(b))
  12. return false
  13. return (a.length == b.length) && a.every(function(element, index) {
  14. return element === b[index];
  15. });
  16. },
  17. hasValue : (a, b) => (a !== void 0) && (Array.isArray(a) ? a.length !==0 : true),
  18. isArray : (a, b) => Array.isArray(a),
  19. hasProperties : (a, b) => {
  20. let res = true
  21. let c = 0
  22. for(let i in a) {
  23. let found = false
  24. for(let j in b) {
  25. c++
  26. if(j === a[i]) {
  27. found = true
  28. break;
  29. }
  30. }
  31. res = res && found
  32. }
  33. return res
  34. }
  35. }