Integer.js 456 B

123456789101112131415161718192021222324252627282930313233
  1. export default class Integer {
  2. constructor(value) {
  3. this.value = value
  4. }
  5. intValue() {
  6. return this.value
  7. }
  8. compareTo(o) {
  9. if (this.value < o)
  10. return -1
  11. if (this.value > o)
  12. return 1
  13. return 0
  14. }
  15. static compare(x, y) {
  16. if (x < y)
  17. return -1
  18. if (x > y)
  19. return 1
  20. return 0
  21. }
  22. static isNan(n) {
  23. return Number.isNaN(n)
  24. }
  25. static valueOf(value) {
  26. return new Integer(value)
  27. }
  28. }