@nxtedition/lib 14.0.18 → 14.0.19
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 +24 -24
- package/package.json +1 -1
package/couch.js
CHANGED
|
@@ -258,8 +258,8 @@ module.exports = function (opts) {
|
|
|
258
258
|
|
|
259
259
|
const src = res.body
|
|
260
260
|
|
|
261
|
-
let resume
|
|
262
|
-
let error
|
|
261
|
+
let resume = null
|
|
262
|
+
let error = null
|
|
263
263
|
let str = ''
|
|
264
264
|
|
|
265
265
|
src
|
|
@@ -282,33 +282,33 @@ module.exports = function (opts) {
|
|
|
282
282
|
} else if (error) {
|
|
283
283
|
throw error
|
|
284
284
|
} else {
|
|
285
|
-
const promise = new Promise((resolve) => {
|
|
286
|
-
resume = resolve
|
|
287
|
-
})
|
|
288
|
-
|
|
289
285
|
const lines = str.split('\n')
|
|
290
|
-
str = lines.pop()
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
286
|
+
str = lines.pop() ?? ''
|
|
287
|
+
|
|
288
|
+
if (lines.length === 0) {
|
|
289
|
+
await new Promise((resolve) => {
|
|
290
|
+
resume = resolve
|
|
291
|
+
})
|
|
292
|
+
} else {
|
|
293
|
+
const results = batched ? [] : null
|
|
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
|
+
}
|
|
303
305
|
}
|
|
304
306
|
}
|
|
305
|
-
}
|
|
306
307
|
|
|
307
|
-
|
|
308
|
-
|
|
308
|
+
if (results?.length) {
|
|
309
|
+
yield results
|
|
310
|
+
}
|
|
309
311
|
}
|
|
310
|
-
|
|
311
|
-
await promise
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
} finally {
|