| 1234567891011121314151617181920212223242526272829 |
- import { createParser } from "./index.js";
- import { ParseError } from "./index.js";
- class EventSourceParserStream extends TransformStream {
- constructor({ onError, onRetry, onComment } = {}) {
- let parser;
- super({
- start(controller) {
- parser = createParser({
- onEvent: (event) => {
- controller.enqueue(event);
- },
- onError(error) {
- onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
- },
- onRetry,
- onComment
- });
- },
- transform(chunk) {
- parser.feed(chunk);
- }
- });
- }
- }
- export {
- EventSourceParserStream,
- ParseError
- };
- //# sourceMappingURL=stream.js.map
|