@nxtedition/lib 14.0.18 → 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
|
|
262
|
-
let error
|
|
263
259
|
let str = ''
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
resume = null
|
|
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 promise = new Promise((resolve) => {
|
|
286
|
-
resume = resolve
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
const lines = str.split('\n')
|
|
290
|
-
str = lines.pop()
|
|
291
|
-
|
|
292
|
-
const results = batched ? [] : null
|
|
293
|
-
for (const line of lines) {
|
|
294
|
-
if (line) {
|
|
295
|
-
const change = JSON.parse(line)
|
|
296
|
-
if (change.seq) {
|
|
297
|
-
params.since = change.seq
|
|
298
|
-
}
|
|
299
|
-
if (results) {
|
|
300
|
-
results.push(change)
|
|
301
|
-
} else {
|
|
302
|
-
yield change
|
|
303
|
-
}
|
|
304
|
-
}
|
|
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
|
|
305
270
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
271
|
+
if (results) {
|
|
272
|
+
results.push(change)
|
|
273
|
+
} else {
|
|
274
|
+
yield change
|
|
309
275
|
}
|
|
310
|
-
|
|
311
|
-
await promise
|
|
312
276
|
}
|
|
313
277
|
}
|
|
314
|
-
|
|
315
|
-
|
|
278
|
+
|
|
279
|
+
if (results?.length) {
|
|
280
|
+
yield results
|
|
281
|
+
}
|
|
316
282
|
}
|
|
317
283
|
}
|
|
318
284
|
|