Skip to content

Commit

Permalink
Common union values method
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed Sep 17, 2021
1 parent a6babe9 commit 496d4f2
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ internal fun tryToUnion(
if (!items.all { it.startsWith('"') })
return null

val values = items
.asSequence()
.map { it.removeSurrounding("\"") }
.filter { !it.startsWith("-moz-") }
.filter { !it.startsWith("-ms-") }
.filter { !it.startsWith("-webkit-") }
.toList()

val enumBody = unionBody(name, values)
val enumBody = unionBody(name, items.toUnionValues())
return ConversionResult(name, enumBody)
}

Expand All @@ -40,14 +32,14 @@ internal fun tryToUnion(
if (!items.all { it.startsWith('"') })
return null

val values = items
.asSequence()
val enumBody = "// Globals\n" + sealedUnionBody(name, items.toUnionValues())
return ConversionResult(name, enumBody)
}

private fun List<String>.toUnionValues(): List<String> =
asSequence()
.map { it.removeSurrounding("\"") }
.filter { !it.startsWith("-moz-") }
.filter { !it.startsWith("-ms-") }
.filter { !it.startsWith("-webkit-") }
.toList()

val enumBody = "// Globals\n" + sealedUnionBody(name, values)
return ConversionResult(name, enumBody)
}

0 comments on commit 496d4f2

Please sign in to comment.