stream.cjs 818 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: !0 });
  3. var index = require("./index.cjs");
  4. class EventSourceParserStream extends TransformStream {
  5. constructor({ onError, onRetry, onComment } = {}) {
  6. let parser;
  7. super({
  8. start(controller) {
  9. parser = index.createParser({
  10. onEvent: (event) => {
  11. controller.enqueue(event);
  12. },
  13. onError(error) {
  14. onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
  15. },
  16. onRetry,
  17. onComment
  18. });
  19. },
  20. transform(chunk) {
  21. parser.feed(chunk);
  22. }
  23. });
  24. }
  25. }
  26. exports.ParseError = index.ParseError;
  27. exports.EventSourceParserStream = EventSourceParserStream;
  28. //# sourceMappingURL=stream.cjs.map