/* * Copyright (c) 2023, Matthew Olsson * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include namespace Web::Streams { JS::ThrowCompletionOr UnderlyingSink::from_value(JS::VM& vm, JS::Value value) { if (!value.is_object()) return UnderlyingSink {}; auto& object = value.as_object(); UnderlyingSink underlying_sink { .start = TRY(property_to_callback(vm, value, "start")), .write = TRY(property_to_callback(vm, value, "write")), .close = TRY(property_to_callback(vm, value, "close")), .abort = TRY(property_to_callback(vm, value, "abort")), .type = {}, }; if (TRY(object.has_property("type"))) underlying_sink.type = TRY(object.get("type")); return underlying_sink; } }