fetch-event-stream
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -39,8 +39,12 @@ import * as utils from './utils.js'; | ||
let iter = utils.stream(res.body); | ||
let line, reader = iter.getReader(); | ||
let event; | ||
let line; | ||
for await (line of iter) { | ||
if (signal && signal.aborted) | ||
break; | ||
if (!line) { | ||
for (;;) { | ||
if (signal && signal.aborted) { | ||
return reader.cancel(); | ||
} | ||
line = await reader.read(); | ||
if (line.done) | ||
return; | ||
if (!line.value) { | ||
if (event) | ||
@@ -51,3 +55,3 @@ yield event; | ||
} | ||
let [field, value] = utils.split(line) || []; | ||
let [field, value] = utils.split(line.value) || []; | ||
if (!field) | ||
@@ -54,0 +58,0 @@ continue; // comment or invalid |
{ | ||
"name": "fetch-event-stream", | ||
"version": "0.1.3", | ||
"description": "A tiny (745b) utility for Server Sent Event (SSE) streaming via `fetch` and Web Streams API", | ||
"version": "0.1.4", | ||
"description": "A tiny (774b) utility for Server Sent Event (SSE) streaming via `fetch` and Web Streams API", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "SSE", |
<!-- deno-fmt-ignore-file --> | ||
# fetch-event-stream [![CI](https://github.com/lukeed/fetch-event-stream/workflows/CI/badge.svg)](https://github.com/lukeed/fetch-event-stream/actions?query=workflow%3ACI) [![licenses](https://licenses.dev/b/npm/fetch-event-stream)](https://licenses.dev/npm/fetch-event-stream) | ||
> A tiny (745b) utility for Server Sent Event (SSE) streaming via `fetch` and Web Streams API | ||
> A tiny (774b) utility for Server Sent Event (SSE) streaming via `fetch` and Web Streams API | ||
@@ -20,2 +20,4 @@ * Allows any HTTP method | ||
> Available on [JSR](https://jsr.io/@lukeed/fetch-event-stream), [npm](https://www.npmjs.com/package/fetch-event-stream), and [deno.land](https://deno.land/x/fetch_event_stream) | ||
``` | ||
@@ -22,0 +24,0 @@ $ npm install --save fetch-event-stream |
@@ -65,8 +65,12 @@ "use strict"; | ||
let iter = utils.stream(res.body); | ||
let line, reader = iter.getReader(); | ||
let event; | ||
let line; | ||
for await (line of iter) { | ||
if (signal && signal.aborted) | ||
break; | ||
if (!line) { | ||
for (;;) { | ||
if (signal && signal.aborted) { | ||
return reader.cancel(); | ||
} | ||
line = await reader.read(); | ||
if (line.done) | ||
return; | ||
if (!line.value) { | ||
if (event) | ||
@@ -77,3 +81,3 @@ yield event; | ||
} | ||
let [field, value] = utils.split(line) || []; | ||
let [field, value] = utils.split(line.value) || []; | ||
if (!field) | ||
@@ -80,0 +84,0 @@ continue; // comment or invalid |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44656
675
125