@spider-cloud/spider-client 0.0.44 → 0.0.46

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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processChunk = void 0;
4
4
  const processChunk = (chunk, cb) => {
5
5
  try {
6
- cb(chunk ? JSON.parse(chunk.trimEnd()) : null);
6
+ cb(chunk ? JSON.parse(chunk.trim()) : null);
7
7
  return true;
8
8
  }
9
9
  catch (_error) {
@@ -8,20 +8,14 @@ const streamReader = async (res, cb) => {
8
8
  if (res.ok) {
9
9
  const reader = (_a = res.body) === null || _a === void 0 ? void 0 : _a.getReader();
10
10
  const decoder = new TextDecoder();
11
- let content = "";
12
11
  if (reader) {
13
12
  while (true) {
14
13
  const { done, value } = await reader.read();
15
14
  if (done) {
16
15
  break;
17
16
  }
18
- content += decoder.decode(value, { stream: true });
19
- if ((0, process_chunk_1.processChunk)(content, cb)) {
20
- content = "";
21
- }
22
- }
23
- if (content.length > 0) {
24
- (0, process_chunk_1.processChunk)(content, cb);
17
+ const chunk = decoder.decode(value, { stream: true });
18
+ (0, process_chunk_1.processChunk)(chunk, cb);
25
19
  }
26
20
  }
27
21
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "description": "A Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
- "test": "node --import tsx --test __tests__/**/*test.ts",
6
+ "test": "node --import tsx --test __tests__/*test.ts",
7
7
  "build": "tsc",
8
8
  "prepublishOnly": "npm test && npm run build"
9
9
  },