Move limit to GetFilterOpts
This commit is contained in:
parent
bbaf1cb012
commit
96641a6fa0
|
@ -50,8 +50,7 @@ function getFilters<K extends number>(filters: Filter<K>[], opts: GetFiltersOpts
|
||||||
sig: event.sig,
|
sig: event.sig,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// HACK
|
if (typeof opts.limit === 'number' && results.length >= opts.limit) {
|
||||||
if (filters.length === 1 && filters[0].limit && results.length >= filters[0].limit) {
|
|
||||||
unsub();
|
unsub();
|
||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
resolve(results as SignedEvent<K>[]);
|
resolve(results as SignedEvent<K>[]);
|
||||||
|
|
|
@ -7,7 +7,10 @@ interface DittoFilter<K extends number = number> extends Filter<K> {
|
||||||
|
|
||||||
/** Additional options to apply to the whole subscription. */
|
/** Additional options to apply to the whole subscription. */
|
||||||
interface GetFiltersOpts {
|
interface GetFiltersOpts {
|
||||||
|
/** How long to wait (in milliseconds) until aborting the request. */
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
/** Event limit for the whole subscription. */
|
||||||
|
limit?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { DittoFilter, GetFiltersOpts };
|
export type { DittoFilter, GetFiltersOpts };
|
||||||
|
|
Loading…
Reference in New Issue