Node.ts 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode';
  2. import { INode } from '../interfaces/nodes/INode';
  3. import { IOptions } from "../interfaces/IOptions";
  4. import { AppendState } from '../enums/AppendState';
  5. export abstract class Node implements ICustomNode {
  6. /**
  7. * @type {AppendState}
  8. */
  9. protected abstract appendState: AppendState;
  10. /**
  11. * @type {IOptions}
  12. */
  13. protected options: IOptions;
  14. /**
  15. * @param options
  16. */
  17. constructor (options: IOptions) {
  18. this.options = options;
  19. }
  20. /**
  21. * @param astTree
  22. */
  23. public abstract appendNode (astTree: INode): void;
  24. /**
  25. * @returns {AppendState}
  26. */
  27. public getAppendState (): AppendState {
  28. return this.appendState;
  29. }
  30. /**
  31. * @returns {INode}
  32. */
  33. public getNode (): INode {
  34. return this.getNodeStructure();
  35. }
  36. /**
  37. * @returns {INode}
  38. */
  39. protected abstract getNodeStructure (): INode;
  40. }