mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-08 18:11:52 +00:00
LibWeb/IDB: Implement create_a_sorted_name_list
This commit is contained in:
parent
3879391fa6
commit
1ad9b3ee6e
Notes:
github-actions[bot]
2025-03-27 15:49:03 +00:00
Author: https://github.com/stelar7
Commit: 1ad9b3ee6e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4077
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
2 changed files with 16 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
|
@ -20,6 +21,7 @@
|
|||
#include <LibWeb/IndexedDB/Internal/Algorithms.h>
|
||||
#include <LibWeb/IndexedDB/Internal/ConnectionQueueHandler.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Database.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
@ -621,4 +623,16 @@ bool is_valid_key_path(KeyPath const& path)
|
|||
});
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#create-a-sorted-name-list
|
||||
GC::Ref<HTML::DOMStringList> create_a_sorted_name_list(JS::Realm& realm, Vector<String> names)
|
||||
{
|
||||
// 1. Let sorted be names sorted in ascending order with the code unit less than algorithm.
|
||||
quick_sort(names, [](auto const& a, auto const& b) {
|
||||
return Infra::code_unit_less_than(a, b);
|
||||
});
|
||||
|
||||
// 2. Return a new DOMStringList associated with sorted.
|
||||
return HTML::DOMStringList::create(realm, names);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue