multiType.js 497 B

123456789101112131415161718192021222324252627282930
  1. import { Type } from "./types";
  2. export class MultiType extends Type {
  3. constructor (...types) {
  4. super(null);
  5. this.types = types;
  6. }
  7. get value () {
  8. return null;
  9. }
  10. get ord () {
  11. return null;
  12. }
  13. isCompatible (another) {
  14. if(another instanceof Type) {
  15. for (let i = 0; i < this.types.length; i++) {
  16. const t = this.types[i];
  17. if (t.isCompatible(another)) {
  18. return true;
  19. }
  20. }
  21. return false;
  22. }
  23. return false;
  24. }
  25. }