Skip to content

Commit

Permalink
TxtBlock: split function definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt committed Mar 7, 2024
1 parent 93570cf commit d8477f1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/txt_block.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@ defmodule TxtBlock do
@type! t :: [] | nonempty_list(lazy(t())) | String.t() | lazy(block)

@spec! to_str_list(t(), module()) :: S.str_list()
def to_str_list(item, service_name) when not is_list(item) do
case item do
txt when is_binary(txt) ->
txt
def to_str_list(txt, service_name)
when is_binary(txt), do: txt

{type, blk} ->
to_str_list(blk, service_name)
|> Service.txt_format(type, service_name)
end
def to_str_list({type, blk}, service_name) do
to_str_list(blk, service_name)
|> Service.txt_format(type, service_name)
end

def to_str_list(blueprint, service_name) when is_list(blueprint) do
def to_str_list(blk, service_name) when is_list(blk) do
# TODO: check performance of flattened vs non-flattened lists
List.foldl(blueprint, [], fn
List.foldl(blk, [], fn
[], acc ->
acc

Expand Down

0 comments on commit d8477f1

Please sign in to comment.