LibJS: Implement Uint8Array.prototype.toBase64

This commit is contained in:
Timothy Flynn
2024-07-15 10:59:29 -04:00
committed by Andreas Kling
parent dfad1a7329
commit b97f9f2c55
6 changed files with 294 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Forward.h>
#include <LibJS/Heap/GCPtr.h>
namespace JS {
class Uint8ArrayPrototypeHelpers {
public:
static void initialize(Realm&, Object& prototype);
private:
JS_DECLARE_NATIVE_FUNCTION(to_base64);
};
enum class Alphabet {
Base64,
Base64URL,
};
ThrowCompletionOr<NonnullGCPtr<TypedArrayBase>> validate_uint8_array(VM&);
ThrowCompletionOr<ByteBuffer> get_uint8_array_bytes(VM&, TypedArrayBase const&);
}