1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:37:45 +00:00

LibJS: Rename Symbol::to_deprecated_string() to descriptive_string()

This implements the spec's SymbolDescriptiveString AO and should be
named accordingly.
This commit is contained in:
Linus Groh 2023-02-11 15:51:44 +00:00
parent ac440e6c0e
commit 89700a2101
7 changed files with 22 additions and 9 deletions

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -22,4 +22,16 @@ NonnullGCPtr<Symbol> Symbol::create(VM& vm, Optional<DeprecatedString> descripti
return vm.heap().allocate_without_realm<Symbol>(move(description), is_global);
}
// 20.4.3.3.1 SymbolDescriptiveString ( sym ), https://tc39.es/ecma262/#sec-symboldescriptivestring
DeprecatedString Symbol::descriptive_string() const
{
// 1. Let desc be sym's [[Description]] value.
// 2. If desc is undefined, set desc to the empty String.
// 3. Assert: desc is a String.
auto description = m_description.value_or("");
// 4. Return the string-concatenation of "Symbol(", desc, and ")".
return DeprecatedString::formatted("Symbol({})", description);
}
}