@nxtedition/lib 15.0.50 → 15.0.52
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 +30 -49
- package/deepstream.js +1 -0
- package/package.json +1 -2
package/couch.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
const stream = require('node:stream')
|
|
2
|
-
const tp = require('node:timers/promises')
|
|
3
1
|
const createError = require('http-errors')
|
|
4
2
|
const makeWeak = require('./weakCache')
|
|
3
|
+
const tp = require('timers/promises')
|
|
5
4
|
const { delay } = require('./http')
|
|
6
|
-
const split2 = require('split2')
|
|
7
5
|
|
|
8
6
|
// https://github.com/fastify/fastify/blob/main/lib/reqIdGenFactory.js
|
|
9
7
|
// 2,147,483,647 (2^31 − 1) stands for max SMI value (an internal optimization of V8).
|
|
@@ -133,7 +131,7 @@ module.exports = function (opts) {
|
|
|
133
131
|
})
|
|
134
132
|
}
|
|
135
133
|
|
|
136
|
-
async function* changes({ client = defaultClient, signal,
|
|
134
|
+
async function* changes({ client = defaultClient, signal, ...options } = {}) {
|
|
137
135
|
const params = {}
|
|
138
136
|
|
|
139
137
|
let body
|
|
@@ -244,59 +242,42 @@ module.exports = function (opts) {
|
|
|
244
242
|
...(body ? { 'content-type': 'application/json' } : {}),
|
|
245
243
|
},
|
|
246
244
|
throwOnError: true,
|
|
247
|
-
highWaterMark:
|
|
245
|
+
highWaterMark: 256 * 1024, // TODO (fix): Needs support in undici...
|
|
248
246
|
bodyTimeout: 2 * (params.heartbeat || 60e3),
|
|
249
247
|
}
|
|
250
248
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
retryCount = 0
|
|
254
|
-
|
|
255
|
-
const src = stream.pipeline(res.body, split2(), () => {})
|
|
256
|
-
|
|
257
|
-
let error
|
|
258
|
-
let ended = false
|
|
259
|
-
let resume = () => {}
|
|
249
|
+
try {
|
|
250
|
+
const res = await client.request(req)
|
|
260
251
|
|
|
261
|
-
|
|
262
|
-
.on('error', (err) => {
|
|
263
|
-
error = err
|
|
264
|
-
})
|
|
265
|
-
.on('readable', () => {
|
|
266
|
-
resume()
|
|
267
|
-
})
|
|
268
|
-
.on('end', () => {
|
|
269
|
-
ended = true
|
|
270
|
-
resume()
|
|
271
|
-
})
|
|
252
|
+
retryCount = 0
|
|
272
253
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
254
|
+
let str = ''
|
|
255
|
+
for await (const chunk of res.body) {
|
|
256
|
+
const lines = (str + chunk).split('\n')
|
|
257
|
+
str = lines.pop() ?? ''
|
|
258
|
+
|
|
259
|
+
const results = batched ? [] : null
|
|
260
|
+
for (const line of lines) {
|
|
261
|
+
if (line) {
|
|
262
|
+
const change = JSON.parse(line)
|
|
263
|
+
if (change.seq) {
|
|
264
|
+
params.since = change.seq
|
|
265
|
+
}
|
|
266
|
+
if (results) {
|
|
267
|
+
results.push(change)
|
|
268
|
+
} else {
|
|
269
|
+
yield change
|
|
270
|
+
}
|
|
271
|
+
}
|
|
283
272
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
yield change
|
|
273
|
+
|
|
274
|
+
if (results?.length) {
|
|
275
|
+
yield results
|
|
288
276
|
}
|
|
289
|
-
} else if (batch?.length) {
|
|
290
|
-
yield batch.splice(0)
|
|
291
|
-
} else if (error) {
|
|
292
|
-
throw Object.assign(error, { data: req })
|
|
293
|
-
} else if (ended) {
|
|
294
|
-
return
|
|
295
|
-
} else {
|
|
296
|
-
await new Promise((resolve) => {
|
|
297
|
-
resume = resolve
|
|
298
|
-
})
|
|
299
277
|
}
|
|
278
|
+
} catch (err) {
|
|
279
|
+
Object.assign(err, { data: req })
|
|
280
|
+
throw err
|
|
300
281
|
}
|
|
301
282
|
}
|
|
302
283
|
|
package/deepstream.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.52",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"files": [
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
"request-target": "^1.0.2",
|
|
90
90
|
"smpte-timecode": "^1.3.3",
|
|
91
91
|
"split-string": "^6.0.0",
|
|
92
|
-
"split2": "^4.2.0",
|
|
93
92
|
"toobusy-js": "^0.5.1",
|
|
94
93
|
"undici": "^5.25.4",
|
|
95
94
|
"url-join": "^4.0.0"
|