DebugProtectionFunctionIntervalNode.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. const NodeType_1 = require('../../enums/NodeType');
  3. const Node_1 = require('../Node');
  4. const NodeUtils_1 = require('../../NodeUtils');
  5. class DebugProtectionFunctionIntervalNode extends Node_1.Node {
  6. constructor(debugProtectionFunctionName, options = {}) {
  7. super(options);
  8. this.debugProtectionFunctionName = debugProtectionFunctionName;
  9. this.node = this.getNodeStructure();
  10. }
  11. appendNode(blockScopeNode) {
  12. NodeUtils_1.NodeUtils.appendNode(blockScopeNode.body, this.getNode());
  13. }
  14. getNodeStructure() {
  15. return {
  16. 'type': NodeType_1.NodeType.ExpressionStatement,
  17. 'expression': {
  18. 'type': NodeType_1.NodeType.CallExpression,
  19. 'callee': {
  20. 'type': NodeType_1.NodeType.Identifier,
  21. 'name': 'setInterval'
  22. },
  23. 'arguments': [
  24. {
  25. 'type': NodeType_1.NodeType.FunctionExpression,
  26. 'id': null,
  27. 'params': [],
  28. 'defaults': [],
  29. 'body': {
  30. 'type': NodeType_1.NodeType.BlockStatement,
  31. 'body': [
  32. {
  33. 'type': NodeType_1.NodeType.ExpressionStatement,
  34. 'expression': {
  35. 'type': NodeType_1.NodeType.CallExpression,
  36. 'callee': {
  37. 'type': NodeType_1.NodeType.Identifier,
  38. 'name': this.debugProtectionFunctionName
  39. },
  40. 'arguments': []
  41. }
  42. }
  43. ]
  44. },
  45. 'generator': false,
  46. 'expression': false
  47. },
  48. {
  49. 'type': NodeType_1.NodeType.Literal,
  50. 'value': 4000,
  51. 'raw': '4000'
  52. }
  53. ]
  54. }
  55. };
  56. }
  57. }
  58. exports.DebugProtectionFunctionIntervalNode = DebugProtectionFunctionIntervalNode;