@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/parser.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vladimirdev635/gql-client",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
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
- const close = () => shouldClose = true;
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 reader.read();
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)