Skip to content

Commit

Permalink
Remove custom type
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgiuliani committed Nov 19, 2023
1 parent ba768ef commit 6eeb754
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "glubs"
version = "0.2.0"
version = "0.3.0"

description = "WebVTT and SRT parser and serializer."

Expand Down
15 changes: 9 additions & 6 deletions src/glubs/webvtt.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ pub type Item {
)
}

type Metadata =
#(String, String)

/// Represents a WebVTT file with an optional comment and a list of items.
pub type WebVTT {
WebVTT(metadata: List(Metadata), comment: Option(String), items: List(Item))
WebVTT(
metadata: List(#(String, String)),
comment: Option(String),
items: List(Item),
)
}

/// Parses a WebVTT string and returns a Result containing the parsed WebVTT structure or a parsing error.
Expand Down Expand Up @@ -65,7 +66,7 @@ fn header_to_string(comment: Option(String)) -> StringBuilder {
}
}

fn metadata_to_string(metadata: List(Metadata)) -> StringBuilder {
fn metadata_to_string(metadata: List(#(String, String))) -> StringBuilder {
case list.is_empty(metadata) {
True -> string_builder.new()
False ->
Expand Down Expand Up @@ -140,7 +141,9 @@ fn settings_to_string(settings: List(#(String, String))) -> StringBuilder {
}
}

fn parse_metadata(metadata: List(String)) -> Result(List(Metadata), String) {
fn parse_metadata(
metadata: List(String),
) -> Result(List(#(String, String)), String) {
metadata
|> list.try_map(fn(meta) {
case string.split_once(meta, ": ") {
Expand Down

0 comments on commit 6eeb754

Please sign in to comment.