* Creates a new EventSource object. * @param {string} url * @param {EventSourceInit} [eventSourceInitDict] * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface
(url, eventSourceInitDict = {})
| 18935 | break; |
| 18936 | case "retry": |
| 18937 | if (isASCIINumber(value)) { |
| 18938 | event[field] = value; |
| 18939 | } |
| 18940 | break; |
| 18941 | case "id": |
| 18942 | if (isValidLastEventId(value)) { |
| 18943 | event[field] = value; |
| 18944 | } |
| 18945 | break; |
| 18946 | case "event": |
| 18947 | if (value.length > 0) { |
| 18948 | event[field] = value; |
| 18949 | } |
| 18950 | break; |
| 18951 | } |
| 18952 | } |
| 18953 | /** |
| 18954 | * @param {EventSourceStreamEvent} event |
| 18955 | */ |
| 18956 | processEvent(event) { |
| 18957 | if (event.retry && isASCIINumber(event.retry)) { |
| 18958 | this.state.reconnectionTime = parseInt(event.retry, 10); |
| 18959 | } |
| 18960 | if (event.id && isValidLastEventId(event.id)) { |
| 18961 | this.state.lastEventId = event.id; |
| 18962 | } |
| 18963 | if (event.data !== void 0) { |
| 18964 | this.push({ |
| 18965 | type: event.event || "message", |
| 18966 | options: { |
| 18967 | data: event.data, |
| 18968 | lastEventId: this.state.lastEventId, |
| 18969 | origin: this.state.origin |
| 18970 | } |
| 18971 | }); |
| 18972 | } |
| 18973 | } |
| 18974 | clearEvent() { |
| 18975 | this.event = { |
| 18976 | data: void 0, |
| 18977 | event: void 0, |
| 18978 | id: void 0, |
| 18979 | retry: void 0 |
| 18980 | }; |
| 18981 | } |
| 18982 | }; |
| 18983 | module.exports = { |
| 18984 | EventSourceStream |
| 18985 | }; |
| 18986 | } |
| 18987 | }); |
| 18988 | |
| 18989 | // |
| 18990 | var require_eventsource = __commonJS({ |
| 18991 | ""(exports, module) { |
| 18992 | "use strict"; |
| 18993 | var { pipeline } = __require("stream"); |
| 18994 | var { fetching } = require_fetch(); |
nothing calls this directly
no test coverage detected