From a984067567d4e84222b92c126c5cd6b0ae93a600 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 3 Jan 2024 13:20:35 -0500 Subject: [PATCH] LibJS: Make the StringIndexOf AO public It will be used outside of String.prototype. --- Userland/Libraries/LibJS/Runtime/StringPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/StringPrototype.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index 9e842002e2..018b9a0bd2 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -64,7 +64,7 @@ static Optional split_match(Utf16View const& haystack, size_t start, Utf } // 6.1.4.1 StringIndexOf ( string, searchValue, fromIndex ), https://tc39.es/ecma262/#sec-stringindexof -static Optional string_index_of(Utf16View const& string, Utf16View const& search_value, size_t from_index) +Optional string_index_of(Utf16View const& string, Utf16View const& search_value, size_t from_index) { // 1. Let len be the length of string. size_t string_length = string.length_in_code_units(); diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.h b/Userland/Libraries/LibJS/Runtime/StringPrototype.h index 5c20ca164b..608859ad3e 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.h @@ -17,6 +17,7 @@ struct CodePoint { size_t code_unit_count { 0 }; }; +Optional string_index_of(Utf16View const& string, Utf16View const& search_value, size_t from_index); CodePoint code_point_at(Utf16View const& string, size_t position); static constexpr Utf8View whitespace_characters = Utf8View("\x09\x0A\x0B\x0C\x0D\x20\xC2\xA0\xE1\x9A\x80\xE2\x80\x80\xE2\x80\x81\xE2\x80\x82\xE2\x80\x83\xE2\x80\x84\xE2\x80\x85\xE2\x80\x86\xE2\x80\x87\xE2\x80\x88\xE2\x80\x89\xE2\x80\x8A\xE2\x80\xAF\xE2\x81\x9F\xE3\x80\x80\xE2\x80\xA8\xE2\x80\xA9\xEF\xBB\xBF"sv); ThrowCompletionOr trim_string(VM&, Value string, TrimMode where);