@nxtedition/lib 19.0.19 → 19.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.
Files changed (2) hide show
  1. package/deepstream.js +11 -9
  2. package/package.json +1 -1
package/deepstream.js CHANGED
@@ -1,3 +1,4 @@
1
+ import assert from 'node:assert'
1
2
  import qs from 'qs'
2
3
  import cached from './util/cached.js'
3
4
  import * as rxjs from 'rxjs'
@@ -133,15 +134,16 @@ function query(ds, designId, options) {
133
134
  ds.record.PROVIDER,
134
135
  )
135
136
  .pipe(
136
- rxjs.switchMap(({ rows, finished }) =>
137
- rows.length < limit && finished
138
- ? rxjs.of({ rows: prevRows ? [...prevRows, ...rows] : rows })
139
- : next(
140
- rows.findLast((x) => x.key), // TODO (fix): Is this correct, is it include or exclusive?
141
- rows,
142
- limit - rows.length,
143
- ),
144
- ),
137
+ rxjs.switchMap(({ rows, finished }) => {
138
+ const nextRows = prevRows ? [...prevRows, ...rows] : rows
139
+ if (rows.length < limit && finished) {
140
+ return rxjs.of({ rows: nextRows })
141
+ } else {
142
+ const last = rows.pop()
143
+ assert(last.key)
144
+ return next(last.key, nextRows, limit - rows.length)
145
+ }
146
+ }),
145
147
  )
146
148
  return next(options.startkey, null, options.limit ?? Infinity)
147
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.0.19",
3
+ "version": "19.0.20",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",