mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibWeb/IDB: Implement IDBIndex::getAllKeys
This commit is contained in:
committed by
Jelle Raaijmakers
parent
3fa1d1299c
commit
b8bb8345a9
Notes:
github-actions[bot]
2025-05-14 15:19:19 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/b8bb8345a9d Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4727 Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/shannonbooth
@@ -1991,4 +1991,32 @@ GC::Ref<JS::Array> retrieve_multiple_referenced_values_from_an_index(JS::Realm&
|
||||
return list;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#retrieve-multiple-values-from-an-index
|
||||
GC::Ref<JS::Array> retrieve_multiple_values_from_an_index(JS::Realm& realm, GC::Ref<Index> index, GC::Ref<IDBKeyRange> range, Optional<WebIDL::UnsignedLong> count)
|
||||
{
|
||||
// 1. If count is not given or is 0 (zero), let count be infinity.
|
||||
if (count.has_value() && *count == 0)
|
||||
count = OptionalNone();
|
||||
|
||||
// 2. Let records be a list containing the first count records in index’s list of records whose key is in range.
|
||||
auto records = index->first_n_in_range(range, count);
|
||||
|
||||
// 3. Let list be an empty list.
|
||||
auto list = MUST(JS::Array::create(realm, records.size()));
|
||||
|
||||
// 4. For each record of records:
|
||||
for (u32 i = 0; i < records.size(); ++i) {
|
||||
auto& record = records[i];
|
||||
|
||||
// 1. Let entry be the result of converting a key to a value with record’s value.
|
||||
auto entry = convert_a_key_to_a_value(realm, record.value);
|
||||
|
||||
// 2. Append entry to list.
|
||||
MUST(list->create_data_property_or_throw(i, entry));
|
||||
}
|
||||
|
||||
// 7. Return list converted to a sequence<any>.
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user