Move limit to GetFilterOpts

This commit is contained in:
Alex Gleason 2023-08-16 21:38:21 -05:00
parent bbaf1cb012
commit 96641a6fa0
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 4 additions and 2 deletions

View File

@ -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>[]);

View File

@ -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 };