LibWeb/IDB: Implement IDBIndex::getAll

This commit is contained in:
stelar7 2025-05-13 22:41:18 +02:00 committed by Jelle Raaijmakers
commit 3fa1d1299c
Notes: github-actions[bot] 2025-05-14 15:19:24 +00:00
7 changed files with 80 additions and 1 deletions

View file

@ -83,4 +83,18 @@ Optional<IndexRecord&> Index::first_in_range(GC::Ref<IDBKeyRange> range)
});
}
GC::ConservativeVector<IndexRecord> Index::first_n_in_range(GC::Ref<IDBKeyRange> range, Optional<WebIDL::UnsignedLong> count)
{
GC::ConservativeVector<IndexRecord> records(range->heap());
for (auto const& record : m_records) {
if (range->is_in_range(record.key))
records.append(record);
if (count.has_value() && records.size() >= *count)
break;
}
return records;
}
}