multiType.js 473 B

1234567891011121314151617181920212223242526272829
  1. import { Type } from "./type";
  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. }
  22. return false;
  23. }
  24. }