Justin
09/26/2019, 5:01 PM*.json
files into kotlin strings. My project targets JVM, JS, and iOS.
My approach was to create a common:
expect fun readFileToString(file: String) : String?
And then implement actuals in each target.
I have iOS and JVM working, but am not sure of the best way to implement the actual
in JS.
Here’s my JVM `actual`:
import java.io.File
actual fun readFileToString(file: String) : String? {
return File(file).readText(Charsets.UTF_8)
}
Anyone done something like this?
I assume I’ll use fs.fileReadSync:
but I’m not sure what I need to import to access that method?Nicholas Bilyk
10/14/2019, 10:14 PMsuspend fun <T> Promise<T>.await(): T = suspendCoroutine { cont ->
then({ cont.resume(it) }, { cont.resumeWithException(it) })
}
Then if there exists a thing in node that isn't in the stdlib for kotlin you can write a definition for it with external fun
.