getFilters: return immediately if filters are empty
This commit is contained in:
parent
4a61ce26a9
commit
05a7a773fe
|
@ -29,6 +29,7 @@ function getPool(): Pool {
|
||||||
|
|
||||||
/** Get events from a NIP-01 filter. */
|
/** Get events from a NIP-01 filter. */
|
||||||
function getFilters<K extends number>(filters: Filter<K>[], opts: GetFiltersOpts = {}): Promise<Event<K>[]> {
|
function getFilters<K extends number>(filters: Filter<K>[], opts: GetFiltersOpts = {}): Promise<Event<K>[]> {
|
||||||
|
if (!filters.length) return Promise.resolve([]);
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let tid: number;
|
let tid: number;
|
||||||
const results: Event[] = [];
|
const results: Event[] = [];
|
||||||
|
|
|
@ -108,6 +108,7 @@ async function getFilters<K extends number>(
|
||||||
filters: DittoFilter<K>[],
|
filters: DittoFilter<K>[],
|
||||||
opts: GetFiltersOpts = {},
|
opts: GetFiltersOpts = {},
|
||||||
): Promise<Event<K>[]> {
|
): Promise<Event<K>[]> {
|
||||||
|
if (!filters.length) return Promise.resolve([]);
|
||||||
let query = filters.map(getFilterQuery).reduce((acc, curr) => acc.union(curr));
|
let query = filters.map(getFilterQuery).reduce((acc, curr) => acc.union(curr));
|
||||||
|
|
||||||
if (typeof opts.limit === 'number') {
|
if (typeof opts.limit === 'number') {
|
||||||
|
|
Loading…
Reference in New Issue