@vladimirdev635/gql-client 0.0.59 → 0.0.61
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/package.json +1 -1
- package/parser.js +10 -2
package/package.json
CHANGED
package/parser.js
CHANGED
|
@@ -20,10 +20,18 @@ export function createParser(parserOptions = defaultParserOptions) {
|
|
|
20
20
|
const reader = rStream.getReader();
|
|
21
21
|
const decoder = new TextDecoder();
|
|
22
22
|
let shouldClose = false;
|
|
23
|
-
|
|
23
|
+
let resolve;
|
|
24
|
+
const signal = new Promise(res => resolve = res);
|
|
25
|
+
const close = () => {
|
|
26
|
+
shouldClose = true;
|
|
27
|
+
resolve({ done: true, value: undefined });
|
|
28
|
+
};
|
|
24
29
|
const stream = async function* () {
|
|
25
30
|
while (!shouldClose) {
|
|
26
|
-
const readResult = await
|
|
31
|
+
const readResult = await Promise.race([
|
|
32
|
+
reader.read(),
|
|
33
|
+
signal
|
|
34
|
+
]);
|
|
27
35
|
if (readResult.done || shouldClose)
|
|
28
36
|
break;
|
|
29
37
|
const lines = decoder.decode(readResult.value)
|