Current section
Files
Jump to
Current section
Files
src/butterbidi@script@types@serialization_options.erl
-module(butterbidi@script@types@serialization_options).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/butterbidi/script/types/serialization_options.gleam").
-export([serialization_options_to_json/1]).
-export_type([serialization_options/0, include_shadow_tree/0]).
-type serialization_options() :: {serialization_options,
gleam@option:option(gleam@option:option(integer())),
gleam@option:option(gleam@option:option(integer())),
gleam@option:option(gleam@option:option(include_shadow_tree()))}.
-type include_shadow_tree() :: include_shadow_tree_none |
include_shadow_tree_open |
include_shadow_tree_all.
-file("src/butterbidi/script/types/serialization_options.gleam", 67).
-spec include_shadow_tree_to_json(include_shadow_tree()) -> gleam@json:json().
include_shadow_tree_to_json(Include_shadow_tree) ->
case Include_shadow_tree of
include_shadow_tree_none ->
gleam@json:string(<<"none"/utf8>>);
include_shadow_tree_open ->
gleam@json:string(<<"open"/utf8>>);
include_shadow_tree_all ->
gleam@json:string(<<"all"/utf8>>)
end.
-file("src/butterbidi/script/types/serialization_options.gleam", 13).
-spec serialization_options_to_json(serialization_options()) -> gleam@json:json().
serialization_options_to_json(Serialization_options) ->
{serialization_options,
Max_dom_depth,
Max_object_depth,
Include_shadow_tree} = Serialization_options,
Max_dom_depth@1 = case Max_dom_depth of
none ->
[];
{some, Value} ->
[{<<"max_dom_depth"/utf8>>, case Value of
none ->
gleam@json:null();
{some, Value@1} ->
gleam@json:int(Value@1)
end}]
end,
Max_object_depth@1 = case Max_object_depth of
none ->
[];
{some, Value@2} ->
[{<<"max_object_depth"/utf8>>, case Value@2 of
none ->
gleam@json:null();
{some, Value@3} ->
gleam@json:int(Value@3)
end}]
end,
Include_shadow_tree@1 = case Include_shadow_tree of
none ->
[];
{some, Value@4} ->
[{<<"include_shadow_tree"/utf8>>, case Value@4 of
none ->
gleam@json:null();
{some, Value@5} ->
include_shadow_tree_to_json(Value@5)
end}]
end,
gleam@json:object(
[{<<"serialization_options"/utf8>>,
gleam@json:object(
begin
_pipe = [],
_pipe@1 = lists:append(_pipe, Max_dom_depth@1),
_pipe@2 = lists:append(_pipe@1, Max_object_depth@1),
lists:append(_pipe@2, Include_shadow_tree@1)
end
)}]
).