@miso.ai/server-commons 0.6.6-beta.11 → 0.6.6-beta.12

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/package.json CHANGED
@@ -24,5 +24,5 @@
24
24
  "uuid": "^9.0.0",
25
25
  "yargs": "^17.5.1"
26
26
  },
27
- "version": "0.6.6-beta.11"
27
+ "version": "0.6.6-beta.12"
28
28
  }
@@ -91,10 +91,10 @@ export default class BufferedReadStream extends Readable {
91
91
  this._debug(`[BufferedReadStream] Load response: ${JSON.stringify(response)} => data = ${data && data.length}`);
92
92
 
93
93
  // TODO: support strategy option: keepOrder = false
94
- this._loads.push(request.index, () => this._resolveLoad(response, data));
94
+ this._loads.push(request.index, () => this._resolveLoad(response, data, request));
95
95
  }
96
96
 
97
- _resolveLoad(response, records) {
97
+ _resolveLoad(response, records, request) {
98
98
  const state = this._state;
99
99
  const strategy = this._strategy;
100
100
 
@@ -104,8 +104,9 @@ export default class BufferedReadStream extends Readable {
104
104
  // apply terminate and filter function
105
105
  let terminate = false;
106
106
  const accepted = [];
107
+ let index = 0;
107
108
  for (const record of records) {
108
- terminate = terminate || strategy.terminate(record, state);
109
+ terminate = terminate || strategy.terminate(record, state, request, index);
109
110
  if (!terminate && this._filter(record)) {
110
111
  state.accept();
111
112
  accepted.push(this._transform(record));
@@ -113,6 +114,7 @@ export default class BufferedReadStream extends Readable {
113
114
  if (terminate) {
114
115
  break;
115
116
  }
117
+ index++;
116
118
  }
117
119
  if (terminate || (this._state.pendingLoads === 0 && this._state.exhausted)) {
118
120
  state.terminate();