Does anyone have an example of writing to the file...
# javascript
a
Does anyone have an example of writing to the file system in kotlin? I can’t seem to find any examples of
Copy code
require('fs').writeFile
ended up just calling that in a
js
block, not sure if that’s correct
d
You can declare
require
to be an
external fun
and then use it from there (it'll return a
dynamic
)
which is almost the same thing as running it in a
js
block
t
Safe variants: 1. Write custom declarations 2. Use autoconversion for TS typings 3. Convert typings using Dukat once
a
I usually declare an
external object FS
annotated with
@JsModule("fs")
and then fill in methods as I need them (adapting callbacks to suspend functions)
👍 1