版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
3.2 KiB

  1. "use strict";
  2. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11. var _require = require('stream'),
  12. Transform = _require.Transform;
  13. var constructTree = require('./construct-tree');
  14. var StreamTreeConstructor =
  15. /*#__PURE__*/
  16. function (_Transform) {
  17. _inherits(StreamTreeConstructor, _Transform);
  18. function StreamTreeConstructor(options) {
  19. var _this;
  20. _classCallCheck(this, StreamTreeConstructor);
  21. _this = _possibleConstructorReturn(this, _getPrototypeOf(StreamTreeConstructor).call(this, Object.assign({}, options, {
  22. objectMode: true,
  23. readableObjectMode: true
  24. })));
  25. _this.currentState = undefined;
  26. return _this;
  27. }
  28. _createClass(StreamTreeConstructor, [{
  29. key: "_transform",
  30. value: function _transform(tokensChunk, encoding, callback) {
  31. var _constructTree = constructTree(tokensChunk, this.currentState),
  32. state = _constructTree.state,
  33. ast = _constructTree.ast;
  34. this.currentState = state;
  35. callback(null, ast);
  36. }
  37. }]);
  38. return StreamTreeConstructor;
  39. }(Transform);
  40. module.exports = StreamTreeConstructor;