@standardserver/fetch 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +4 -4
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -35,12 +35,11 @@ interface ToEventStreamOptions {
|
|
|
35
35
|
*/
|
|
36
36
|
initialComment?: string;
|
|
37
37
|
/**
|
|
38
|
-
* If
|
|
39
|
-
* By default, a 'close' event is always sent when the iterator completes.
|
|
38
|
+
* If true, no `close` event is sent when the iterator completes with `undefined`.
|
|
40
39
|
*
|
|
41
40
|
* @default true
|
|
42
41
|
*/
|
|
43
|
-
|
|
42
|
+
omitEmptyCloseEvent?: boolean;
|
|
44
43
|
}
|
|
45
44
|
declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
46
45
|
|
package/dist/index.d.ts
CHANGED
|
@@ -35,12 +35,11 @@ interface ToEventStreamOptions {
|
|
|
35
35
|
*/
|
|
36
36
|
initialComment?: string;
|
|
37
37
|
/**
|
|
38
|
-
* If
|
|
39
|
-
* By default, a 'close' event is always sent when the iterator completes.
|
|
38
|
+
* If true, no `close` event is sent when the iterator completes with `undefined`.
|
|
40
39
|
*
|
|
41
40
|
* @default true
|
|
42
41
|
*/
|
|
43
|
-
|
|
42
|
+
omitEmptyCloseEvent?: boolean;
|
|
44
43
|
}
|
|
45
44
|
declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
46
45
|
|
package/dist/index.mjs
CHANGED
|
@@ -40,8 +40,8 @@ function toEventIterator(stream) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
}, async (
|
|
44
|
-
if (
|
|
43
|
+
}, async (state) => {
|
|
44
|
+
if (state.isCancelled) {
|
|
45
45
|
isCancelled = true;
|
|
46
46
|
}
|
|
47
47
|
await reader?.cancel();
|
|
@@ -53,7 +53,7 @@ function toEventStream(iterator, options = {}) {
|
|
|
53
53
|
const keepAliveComment = options.keepAliveComment ?? "";
|
|
54
54
|
const initialCommentEnabled = options.initialCommentEnabled ?? true;
|
|
55
55
|
const initialComment = options.initialComment ?? "";
|
|
56
|
-
const
|
|
56
|
+
const omitEmptyCloseEvent = options.omitEmptyCloseEvent ?? true;
|
|
57
57
|
let cancelled = false;
|
|
58
58
|
let timeout;
|
|
59
59
|
const stream = new ReadableStream({
|
|
@@ -79,7 +79,7 @@ function toEventStream(iterator, options = {}) {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
const [data, meta] = unwrapEventIteratorEvent(result.value);
|
|
82
|
-
if (
|
|
82
|
+
if (!omitEmptyCloseEvent || !result.done || data !== void 0 || meta !== void 0) {
|
|
83
83
|
const event = result.done ? "close" : "message";
|
|
84
84
|
controller.enqueue(encodeEventStreamMessage({
|
|
85
85
|
...meta,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardserver/fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://standardserver.dev",
|
|
7
7
|
"repository": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@standardserver/
|
|
24
|
-
"@standardserver/
|
|
23
|
+
"@standardserver/shared": "0.0.10",
|
|
24
|
+
"@standardserver/core": "0.0.10"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@hono/node-server": "^1.19.7"
|