diff --git a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/NonEmptyList.kt b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/NonEmptyList.kt index d5166c7..8661961 100644 --- a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/NonEmptyList.kt +++ b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/NonEmptyList.kt @@ -1,7 +1,11 @@ package com.quickbirdstudios.nonEmptyCollection.list import com.quickbirdstudios.nonEmptyCollection.NonEmptyCollection +import kotlin.js.ExperimentalJsExport +import kotlin.js.JsExport +@OptIn(ExperimentalJsExport::class) +@JsExport class NonEmptyList internal constructor( internal val full: List ) : List by full, NonEmptyCollection { diff --git a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/nonEmptyListOf.kt b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/nonEmptyListOf.kt index b8a04e4..d69322a 100644 --- a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/nonEmptyListOf.kt +++ b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/list/nonEmptyListOf.kt @@ -2,10 +2,17 @@ package com.quickbirdstudios.nonEmptyCollection.list +import kotlin.js.ExperimentalJsExport +import kotlin.js.JsExport + +@OptIn(ExperimentalJsExport::class) +@JsExport fun nonEmptyListOf(value: T, vararg values: T) = nonEmptyListOf(value, values.asList()) fun nonEmptyListOf(value: T, values: List) = NonEmptyList(value, values) +@OptIn(ExperimentalJsExport::class) +@JsExport fun nonEmptyListOfNotNull( value: T, vararg values: T? diff --git a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/NonEmptySet.kt b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/NonEmptySet.kt index 4bdedd8..a7405a4 100644 --- a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/NonEmptySet.kt +++ b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/NonEmptySet.kt @@ -1,7 +1,11 @@ package com.quickbirdstudios.nonEmptyCollection.set import com.quickbirdstudios.nonEmptyCollection.NonEmptyCollection +import kotlin.js.ExperimentalJsExport +import kotlin.js.JsExport +@OptIn(ExperimentalJsExport::class) +@JsExport class NonEmptySet internal constructor( internal val full: Set ) : Set by full, NonEmptyCollection { diff --git a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/nonEmptySetOf.kt b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/nonEmptySetOf.kt index 079af31..8cc1168 100644 --- a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/nonEmptySetOf.kt +++ b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/set/nonEmptySetOf.kt @@ -2,10 +2,17 @@ package com.quickbirdstudios.nonEmptyCollection.set +import kotlin.js.ExperimentalJsExport +import kotlin.js.JsExport + +@OptIn(ExperimentalJsExport::class) +@JsExport fun nonEmptySetOf(value: T, vararg values: T) = nonEmptySetOf(value, values.toSet()) fun nonEmptySetOf(value: T, values: Set): NonEmptySet = NonEmptySet(value, values) +@OptIn(ExperimentalJsExport::class) +@JsExport fun nonEmptySetOfNotNull( value: T, vararg values: T? diff --git a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/toNonEmptyOrNull.kt b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/toNonEmptyOrNull.kt index bf52c0e..4a56987 100644 --- a/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/toNonEmptyOrNull.kt +++ b/src/commonMain/kotlin/com/quickbirdstudios/nonEmptyCollection/toNonEmptyOrNull.kt @@ -7,9 +7,19 @@ import com.quickbirdstudios.nonEmptyCollection.unsafe.UnsafeNonEmptyCollectionAp import com.quickbirdstudios.nonEmptyCollection.unsafe.toNonEmptyList import com.quickbirdstudios.nonEmptyCollection.unsafe.toNonEmptyMap import com.quickbirdstudios.nonEmptyCollection.unsafe.toNonEmptySet +import kotlin.js.ExperimentalJsExport +import kotlin.js.JsExport fun List.toNonEmptyListOrNull() = if (isEmpty()) null else toNonEmptyList() fun Set.toNonEmptySetOrNull() = if (isEmpty()) null else toNonEmptySet() fun Map.toNonEmptyMapOrNull() = if (isEmpty()) null else toNonEmptyMap() + +@OptIn(ExperimentalJsExport::class) +@JsExport +fun Array.toNonEmptyListOrNull() = toList().toNonEmptyListOrNull() + +@OptIn(ExperimentalJsExport::class) +@JsExport +fun Array.toNonEmptySetOrNull() = toSet().toNonEmptySetOrNull()