diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a4ef01..f9b7aad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.1.2 * All reflection support methods are internal +* Added `lodModule` functions for more useful working with modules loading ## 0.1.1 diff --git a/src/commonMain/kotlin/com/insanusmokrassar/sdi/HelperTools.kt b/src/commonMain/kotlin/com/insanusmokrassar/sdi/HelperTools.kt new file mode 100644 index 0000000..dc40876 --- /dev/null +++ b/src/commonMain/kotlin/com/insanusmokrassar/sdi/HelperTools.kt @@ -0,0 +1,7 @@ +package com.insanusmokrassar.sdi + +import kotlinx.serialization.ImplicitReflectionSerializer +import kotlinx.serialization.json.Json + +@ImplicitReflectionSerializer +fun loadModule(json: String): Module = Json.nonstrict.parse(Module.serializer(), json) diff --git a/src/jvmMain/kotlin/com/insanusmokrassar/sdi/JVMHelperTools.kt b/src/jvmMain/kotlin/com/insanusmokrassar/sdi/JVMHelperTools.kt new file mode 100644 index 0000000..b5c4804 --- /dev/null +++ b/src/jvmMain/kotlin/com/insanusmokrassar/sdi/JVMHelperTools.kt @@ -0,0 +1,11 @@ +package com.insanusmokrassar.sdi + +import kotlinx.io.InputStream +import kotlinx.serialization.ImplicitReflectionSerializer +import java.io.File + +@ImplicitReflectionSerializer +fun loadModule(stream: InputStream) = loadModule(stream.reader().readText()) + +@ImplicitReflectionSerializer +fun loadModule(file: File) = loadModule(file.inputStream())