@@ -131,6 +131,11 @@ export class Controller<T extends FactorsType> {
131
131
this . row . consumed . set ( pairKey , pair ) ;
132
132
}
133
133
}
134
+ public consumeRow ( row : Row ) {
135
+ for ( let pair of combinations ( [ ...row . values ( ) ] , this . pairwiseCount ) ) {
136
+ this . consume ( pair ) ;
137
+ }
138
+ }
134
139
135
140
public getCandidate ( pair : PairType ) {
136
141
return getCandidate ( pair , this . parents ) ;
@@ -156,6 +161,7 @@ export class Controller<T extends FactorsType> {
156
161
try {
157
162
const ok = this . options . preFilter ( proxy ) ;
158
163
if ( ! ok ) {
164
+ this . consumeRow ( nxt ) ;
159
165
return null ;
160
166
}
161
167
} catch ( e ) {
@@ -206,7 +212,8 @@ export class Controller<T extends FactorsType> {
206
212
}
207
213
208
214
private discard ( ) {
209
- this . rejected . add ( this . row . getPairKey ( ) ) ;
215
+ const pairKey = this . row . getPairKey ( ) ;
216
+ this . rejected . add ( pairKey ) ;
210
217
this . row = new Row ( [ ] ) ;
211
218
}
212
219
@@ -268,7 +275,7 @@ export class Controller<T extends FactorsType> {
268
275
}
269
276
const proxy = this . toProxy ( this . row ) ;
270
277
try {
271
- return this . options . preFilter ? this . options . preFilter ( proxy ) : true ;
278
+ return this . options . preFilter ?. ( proxy ) ?? true ;
272
279
} catch ( e ) {
273
280
if ( e instanceof NotReady ) {
274
281
return false ;
@@ -284,7 +291,7 @@ export class Controller<T extends FactorsType> {
284
291
return 1 - this . incomplete . size / this . numAllChunks ;
285
292
}
286
293
287
- public * makeAsync < T extends FactorsType > ( ) : Generator < SuggestRowType < T > , void , unknown > {
294
+ public * makeAsync < T extends FactorsType > ( ) {
288
295
const { criterion = greedy , postFilter} = this . options ;
289
296
do {
290
297
for ( let pair of criterion ( this ) ) {
@@ -309,5 +316,6 @@ export class Controller<T extends FactorsType> {
309
316
throw e ;
310
317
}
311
318
} while ( this . incomplete . size ) ;
319
+ this . incomplete . clear ( ) ;
312
320
}
313
321
}
0 commit comments