Node.js 576 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. class Node {
  3. constructor(node) {
  4. this.type = node.type;
  5. if (node.value) this.value = node.value;
  6. if (node.match) this.match = node.match;
  7. this.newline = node.newline || '';
  8. }
  9. get protected() {
  10. return Boolean(this.match) && this.match[1] === '!';
  11. }
  12. }
  13. class Block extends Node {
  14. constructor(node) {
  15. super(node);
  16. this.nodes = node.nodes || [];
  17. }
  18. push(node) {
  19. this.nodes.push(node);
  20. }
  21. get protected() {
  22. return this.nodes.length > 0 && this.nodes[0].protected === true;
  23. }
  24. }
  25. module.exports = { Node, Block };