@nxtedition/lib 14.0.19 → 14.0.20
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/couch.js +18 -52
- package/package.json +1 -1
package/couch.js
CHANGED
|
@@ -256,63 +256,29 @@ module.exports = function (opts) {
|
|
|
256
256
|
|
|
257
257
|
retryCount = 0
|
|
258
258
|
|
|
259
|
-
const src = res.body
|
|
260
|
-
|
|
261
|
-
let resume = null
|
|
262
|
-
let error = null
|
|
263
259
|
let str = ''
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
try {
|
|
278
|
-
while (true) {
|
|
279
|
-
const chunk = src.read()
|
|
280
|
-
if (chunk !== null) {
|
|
281
|
-
str += chunk
|
|
282
|
-
} else if (error) {
|
|
283
|
-
throw error
|
|
284
|
-
} else {
|
|
285
|
-
const lines = str.split('\n')
|
|
286
|
-
str = lines.pop() ?? ''
|
|
287
|
-
|
|
288
|
-
if (lines.length === 0) {
|
|
289
|
-
await new Promise((resolve) => {
|
|
290
|
-
resume = resolve
|
|
291
|
-
})
|
|
260
|
+
for await (const chunk of res.body) {
|
|
261
|
+
const lines = (str + chunk).split('\n')
|
|
262
|
+
str = lines.pop() ?? ''
|
|
263
|
+
|
|
264
|
+
const results = batched ? [] : null
|
|
265
|
+
for (const line of lines) {
|
|
266
|
+
if (line) {
|
|
267
|
+
const change = JSON.parse(line)
|
|
268
|
+
if (change.seq) {
|
|
269
|
+
params.since = change.seq
|
|
270
|
+
}
|
|
271
|
+
if (results) {
|
|
272
|
+
results.push(change)
|
|
292
273
|
} else {
|
|
293
|
-
|
|
294
|
-
for (const line of lines) {
|
|
295
|
-
if (line) {
|
|
296
|
-
const change = JSON.parse(line)
|
|
297
|
-
if (change.seq) {
|
|
298
|
-
params.since = change.seq
|
|
299
|
-
}
|
|
300
|
-
if (results) {
|
|
301
|
-
results.push(change)
|
|
302
|
-
} else {
|
|
303
|
-
yield change
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (results?.length) {
|
|
309
|
-
yield results
|
|
310
|
-
}
|
|
274
|
+
yield change
|
|
311
275
|
}
|
|
312
276
|
}
|
|
313
277
|
}
|
|
314
|
-
|
|
315
|
-
|
|
278
|
+
|
|
279
|
+
if (results?.length) {
|
|
280
|
+
yield results
|
|
281
|
+
}
|
|
316
282
|
}
|
|
317
283
|
}
|
|
318
284
|
|