Files
serenity/Userland/Libraries/LibJS/Runtime/KeyedCollections.cpp
Timothy Flynn 0bbf42bca7 LibJS: Introduce the CanonicalizeKeyedCollectionKey AO
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/30257dd

(cherry picked from commit 55b4ef79157f299e68163824d8d03dfab31dd3d6)
2024-07-14 16:45:08 -04:00

23 lines
485 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/KeyedCollections.h>
namespace JS {
// 24.5.1 CanonicalizeKeyedCollectionKey ( key ), https://tc39.es/ecma262/#sec-canonicalizekeyedcollectionkey
Value canonicalize_keyed_collection_key(Value key)
{
// 1. If key is -0𝔽, return +0𝔽.
if (key.is_negative_zero())
return Value { 0.0 };
// 2. Return key.
return key;
}
}