From 2a186edf3a7e15c6efb1b4ba265516824c34940d Mon Sep 17 00:00:00 2001 From: sksamuel Date: Sat, 30 Dec 2023 13:54:15 -0600 Subject: [PATCH] Updated docs --- .../kotlin/com/sksamuel/tribune/core/collections/lists.kt | 4 ++++ .../main/kotlin/com/sksamuel/tribune/core/collections/sets.kt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/lists.kt b/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/lists.kt index 35fbb43..e002fd5 100644 --- a/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/lists.kt +++ b/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/lists.kt @@ -31,4 +31,8 @@ fun Parser.asList(): Parser, List, E> { fun Parser.Companion.list(elementParser: Parser): Parser, List, E> = elementParser.asList() +/** + * Wraps a [Parser] that produces lists with nullable items, to filter any null entries in the outputted list. + * In other words, transforms a Parser I -> List to I -> List. + */ fun Parser, E>.filterNulls(): Parser, E> = map { it.filterNotNull() } diff --git a/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/sets.kt b/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/sets.kt index 0e0be8a..4a930c6 100644 --- a/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/sets.kt +++ b/tribune-core/src/main/kotlin/com/sksamuel/tribune/core/collections/sets.kt @@ -30,5 +30,9 @@ fun Parser.asSet(): Parser, Set, E> { fun Parser, E>.filterNulls(): Parser, E> = map { it.filterNotNull().toSet() } +/** + * Wraps a [Parser] that produces sets with nullable items, to filter any null entries in the outputted set. + * In other words, transforms a Parser I -> Set to I -> Set. + */ fun Parser.Companion.set(elementParser: Parser): Parser, Set, E> = elementParser.asSet()