mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 11:39:43 +00:00
LibWeb/IDB: Implement retrieve_multiple_keys_from_an_object_store
This commit is contained in:
parent
c56ec49ce6
commit
927237c736
Notes:
github-actions[bot]
2025-05-12 20:29:11 +00:00
Author: https://github.com/stelar7
Commit: 927237c736
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4662
Reviewed-by: https://github.com/shannonbooth ✅
2 changed files with 29 additions and 0 deletions
|
@ -1901,4 +1901,32 @@ GC::Ref<JS::Array> retrieve_multiple_values_from_an_object_store(JS::Realm& real
|
|||
return list;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#retrieve-multiple-keys-from-an-object-store
|
||||
GC::Ref<JS::Array> retrieve_multiple_keys_from_an_object_store(JS::Realm& realm, GC::Ref<ObjectStore> store, 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 store’s list of records whose key is in range.
|
||||
auto records = store->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 key.
|
||||
auto entry = convert_a_key_to_a_value(realm, record.key);
|
||||
|
||||
// 2. Append entry to list.
|
||||
MUST(list->create_data_property_or_throw(i, entry));
|
||||
}
|
||||
|
||||
// 5. Return list converted to a sequence<any>.
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,5 +49,6 @@ GC::Ptr<IDBCursor> iterate_a_cursor(JS::Realm&, GC::Ref<IDBCursor>, GC::Ptr<Key>
|
|||
JS::Value clear_an_object_store(GC::Ref<ObjectStore>);
|
||||
JS::Value retrieve_a_key_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>);
|
||||
GC::Ref<JS::Array> retrieve_multiple_values_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>, Optional<WebIDL::UnsignedLong>);
|
||||
GC::Ref<JS::Array> retrieve_multiple_keys_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>, Optional<WebIDL::UnsignedLong>);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue