stream-to-sw
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -106,7 +106,5 @@ async function nextSWPostMessage () { | ||
// if string is returned, pass it as an array of one ArrayBuffer | ||
if (typeof asyncIterator === 'string') { | ||
asyncIterator = | ||
asyncIterator | ||
.split(/(?=\n)/) // split into array of lines (regex splits without removing the newlines) | ||
.map(line => new TextEncoder().encode(line)) // convert to Uint8Arrays | ||
asyncIterator = [new TextEncoder().encode(asyncIterator)] | ||
} | ||
@@ -113,0 +111,0 @@ |
{ | ||
"name": "stream-to-sw", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "intercept fetch requests with a service worker, but process the response on the main thread", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -109,3 +109,3 @@ # stream-to-sw | ||
A plain string can be also be returned from the requestHandler, and it will be automatically converted into an array of Uint8Arrays (one for each line) using [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) | ||
A plain string can be also be returned from the requestHandler, and it will be automatically converted into an arrayBuffer using [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) | ||
@@ -112,0 +112,0 @@ If nothing is returned, the response body is empty. |
25990
458